小编Mar*_*Bro的帖子

在espresso中,我如何测试textview仅显示两行

我有一个TextView,其中包含以下文本:"line1.\nline2.\n line3"。我将TextView的末尾设置为椭圆形,并限制为最多两行。为了测试它是否显示椭圆,我有以下代码

public static final String TEST_BODY = "line1.\nline2.\nline3.";
//a setup method is called so that mail_cell_body_preview_field is set to above TEST_BODY
//...  

public void testMessageSnippetIsVisible() {
    onView(withId(R.id.mail_cell_body_preview_field)).check(matches(isDisplayed()));
    onView(withId(R.id.mail_cell_body_preview_field)).check(matches(hasEllipsizedText()));
    onView(withId(R.id.mail_cell_body_preview_field)).check(matches(withText(TEST_BODY)));
    //Add statement to verify that line3 not visible in UI           
}
Run Code Online (Sandbox Code Playgroud)

如何编写测试用例以验证UI中的第三行不可见?

android android-espresso

3
推荐指数
1
解决办法
1652
查看次数

设置多个警报时仅触发一个警报

我的目标是为每个事件发出警报,eventsDb.getFavouriteEvents()但每次事件只发射一次.

在我看来,它可能是由设置引起的PendingIntent.FLAG_UPDATE_CURRENT,但是我需要这个标志来发布具有意图的额外内容.有没有办法不设置这个标志,仍然有意图发布Extras?

我存储PendinIntents在Collection(pendingIntents)中因为我在onDestroy()这个Service类中取消它们.

这是来自的代码onCreate():

for(Event event : eventsDB.getFavouriteEvents()) {
  Intent intent = new Intent(AlarmReciever.ONCOMING_EVENT);
  intent.putExtra(Event.TITLE, event.getTitle());

  PendingIntent pendingIntent = PendingIntent.getBroadcast(EventAlarmService.this, 0, intent, 
    Intent.FLAG_GRANT_READ_URI_PERMISSION | PendingIntent.FLAG_UPDATE_CURRENT);
  alarmManager.set(AlarmManager.RTC_WAKEUP, event.getTime(), pendingIntent);

  pendingIntents.add(pendingIntent);
}
Run Code Online (Sandbox Code Playgroud)

感谢帮助!

flags android android-alarms android-pendingintent

2
推荐指数
1
解决办法
172
查看次数

使用eclipse在我的项目中没有重新创建Crashlytics库

我在我的eclipse Android项目中使用了Crashlytics(现在是Fabric的一部分).从文件系统中删除后,四个自动添加的Crashlytics库不会在我的项目中重新创建.

  • 重启eclipse没有帮助
  • 重新安装Fabric插件没有帮助

该插件说它已正确安装,但我无法导入:

io.fabric.sdk.android.Fabric;
com.crashlytics.android.Crashlytics;
Run Code Online (Sandbox Code Playgroud)

有没有人来过类似的情况?


详细描述了我是怎么发生的:

当我第一次安装插件时,插件已集成到我的项目中.它添加了几个.properties文件和4个库(将它们奇怪地嵌套到/ kit-libs /下的项目文件夹中,并将它们添加到我的工作区,即使只有一个被设置为我的项目的库项目)..呃好吧,不能说我喜欢这种融合方式.

无论如何,我删除了这些自动创建的库,因为我切换到我的项目的旧提交,当时没有使用Fabric,我需要快速进行构建.我没有为这个项目使用任何构建工具,我没有找到有关如何删除插件的任何信息,所以我只是从文件系统中删除了库并删除了库项目.

当我切换回当前提交时,库被重新创建.但是我需要再次做同样的事情,所以我切换到旧的提交,删除了库文件夹,删除了库项目并完成了我的工作.但是,在我切换回新提交后,4个库不再被重新创建.

任何提示都会很高兴.

eclipse android crashlytics

2
推荐指数
1
解决办法
5734
查看次数

ClassNotFoundException:在 Android 9 上找不到类 SchemeRegistry

我正在使用以下 OkHttp API 来设置 SSL 工厂:

OkHttpClient.Builder.sslSocketFactory(sslContext.getSocketFactory(), x509TrustManager);
Run Code Online (Sandbox Code Playgroud)

为了得到sslContext我需要创建SchemeRegistry

SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("https", new SslSocketFactory(sslContext), 443));
Run Code Online (Sandbox Code Playgroud)

但是,这会产生以下崩溃:

ClassNotFoundException: Didn't find class "org.apache.http.conn.scheme.SchemeRegistry"
Run Code Online (Sandbox Code Playgroud)

我该怎么做才能避免崩溃?

android classnotfoundexception okhttp3 android-9.0-pie

2
推荐指数
1
解决办法
1139
查看次数

Java中类的构造函数中的参数有什么问题?

在此代码中,如果我保留int i在参数化构造函数中,则会引发错误.除非int i工作正常.

示例:int j工作正常.这个错误的原因是什么,请指教我的知识.

//this program throws an error
class X
{ 
    final int i;
    X()
    {
        i = 0;
    }
    X(int i)//need to keep other than i
    {
        i = 20;
    }
}

//this program works fine
class X
{ 
    final int i;
    X()
    {
        i = 0;
    }   
    X(int j)
    {
        i = 20;
    }
}
Run Code Online (Sandbox Code Playgroud)

java constructor final

2
推荐指数
1
解决办法
70
查看次数