我有以下测试,它返回false.我错过了什么吗?
TextUtils.isEmpty("")
Run Code Online (Sandbox Code Playgroud)
更新:由于某种原因,我无法回答我的问题或添加评论.我正在运行JUNit测试用例而不是仪器测试用例.因为,我建议我发现当我们不作为Instrumentation运行时,上面的方法返回不正确的值.谢谢大家的帮助.我赞成了答案并正确评论.
我正在使用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
我最近开始更新 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 的其他方式有任何建议,我将不胜感激。