小编Aks*_*hay的帖子

TextUtils.isEmpty()方法为空字符串返回false

我有以下测试,它返回false.我错过了什么吗?

TextUtils.isEmpty("")
Run Code Online (Sandbox Code Playgroud)

更新:由于某种原因,我无法回答我的问题或添加评论.我正在运行JUNit测试用例而不是仪器测试用例.因为,我建议我发现当我们不作为Instrumentation运行时,上面的方法返回不正确的值.谢谢大家的帮助.我赞成了答案并正确评论.

android

6
推荐指数
1
解决办法
2048
查看次数

是否可以在Android Oreo上更改通知Dot的颜色

Android Oreo可以选择显示任何新推送通知的通知点.但是,在任何地方都没有记录是否可以以编程方式更改通知点的颜色.

在此输入图像描述

有什么建议?

android push-notification android-8.0-oreo

5
推荐指数
1
解决办法
6497
查看次数

问题从IntentService迁移到Android O的JobIntentService

我正在使用Intent Service来监控Geofence过渡.为此,我正在使用Sticky Service的跟随电话.

 LocationServices.GeofencingApi.addGeofences(
                    mGoogleApiClient,
                    getGeofencingRequest(),
                    getGeofencePendingIntent()
            )
Run Code Online (Sandbox Code Playgroud)

Pending Intent调用Transition Service(IntentService),如下所示.

  private PendingIntent getGeofencePendingIntent() {
        Intent intent = new Intent(this, GeofenceTransitionsIntentService.class);
        // We use FLAG_UPDATE_CURRENT so that we get the 
          //same pending intent back when calling addgeoFences()
        return PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    }
Run Code Online (Sandbox Code Playgroud)

这工作很好Pre Oreo.但是,我必须将我的粘性服务转换为JobScheduler,我需要将GeofenceTransitionsIntentService哪个是intentService 转换为JobIntentService.

说过我不知道如何返回为JobIntentService创建一个PendingIntent,因为我需要为JobIntentService调用enqueueWork.

任何建议/指针将不胜感激.

android android-geofence android-service-binding android-8.0-oreo

3
推荐指数
2
解决办法
6367
查看次数

OkHttp 4.x 尝试通过呼叫请求访问 url 时出错

我最近开始更新 okhttp3 到 4.x

在这样做时,我收到以下构建时间错误:

Using 'url(): HttpUrl' is an error. moved to val

当我尝试从通过调用获得的请求对象中获取 url 时,问题发生了:

例如

   call.enque(callback : Callback){
     override fun onFailure(call : Call, t:Throwable) {
       val url = call.request().url().toString
     }
   }
Run Code Online (Sandbox Code Playgroud)

我进一步抬头,里面的Url物体Request现在是 val aka final。

此外,他们的升级指南https://square.github.io/okhttp/upgrading_to_okhttp_4/上没有说明

如果您对获取 Url 的其他方式有任何建议,我将不胜感激。

android kotlin okhttp

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