【发布时间】:2019-10-03 21:25:15
【问题描述】:
我有三部 Pixel 手机,它们在检查片段中的位置权限时都会显示这种行为。
当 wifi 关闭时,checkLocationSettings 方法的 result.isSuccessful() 总是返回 false。实在是看不懂,好像Pixel不知道怎么处理没有wifi的位置请求。
请注意,如果您打开扫描 wifi 网络,它将再次开始正常工作。
这是我的应用程序所采用的过程:
1) Activity 请求位置权限并被授予。 (这一切都很好)。
2) 稍后运行的片段检查授予的位置权限并要求更新位置。
片段代码:
locationRequest = LocationRequest.create();
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationRequest.setInterval(UPDATE_INTERVAL);
locationRequest.setFastestInterval(FASTEST_INTERVAL);
LocationSettingsRequest.Builder builder = new
LocationSettingsRequest.Builder().addLocationRequest(locationRequest);
SettingsClient client = LocationServices.getSettingsClient(activity);
Task<LocationSettingsResponse> task = client.checkLocationSettings(builder.build());
task.addOnCompleteListener(result -> {
if (result.isSuccessful()) {
fusedLocationClient.requestLocationUpdates(
...
}else{
//Always end up here
//com.google.android.gms.common.api.ResolvableApiException: 6: RESOLUTION_REQUIRED
Exception locExcep = result.getException();
Log.e(TAG, "startLocationUpdates failed: ", locExcep);
}
适用于我能拿到的所有其他手机。所有代码几乎相同:
https://developer.android.com/training/location/change-location-settings.html
https://developer.android.com/training/location/receive-location-updates
错误是:
com.google.android.gms.common.api.ResolvableApiException: 6: RESOLUTION_REQUIRED
at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(Unknown Source:3)
at com.google.android.gms.common.internal.zai.zaf(Unknown Source:2)
at com.google.android.gms.common.internal.zaj.onComplete(Unknown Source:6)
at com.google.android.gms.common.api.internal.BasePendingResult.zaa(Unknown Source:172)
at com.google.android.gms.common.api.internal.BasePendingResult.setResult(Unknown Source:131)
at com.google.android.gms.common.api.internal.BaseImplementation$ApiMethodImpl.setResult(Unknown Source:36)
at com.google.android.gms.internal.location.zzbc.zza(Unknown Source:2)
at com.google.android.gms.internal.location.zzar.dispatchTransaction(Unknown Source:11)
at com.google.android.gms.internal.location.zzb.onTransact(Unknown Source:22)
at android.os.Binder.execTransact(Binder.java:731)
【问题讨论】:
-
对此的任何解决方案。最近更新到 Android 10 的 VIVO 手机也面临同样的问题。
-
请更新?
-
面临同样的问题
标签: android google-play-services