已解决 - 答案在最后
我正在使用新方法从 Google Play Services 7.0 检索位置:
http://android-developers.blogspot.com/2015/03/google-play-services-70-places-everyone.html http://android-developers.blogspot.com/2015/03/google-play-services-70-places-everyone.html
https://developer.android.com/reference/com/google/android/gms/location/SettingsApi.html https://developer.android.com/reference/com/google/android/gms/location/SettingsApi.html
一开始,它只给我们两个选项,“取消”和“打开”(如下图)。
但今天我看到了 Google Play 服务新更新的新“功能” - 当我的位置关闭并尝试通过 Google Play 服务获取它时,弹出的对话框给了我选项:
是的,从来没有。当我点击它时,我的应用程序将永远不会通过 Google Play 服务获取位置,即使它已打开并且我没有其他选择,只能重新安装应用程序或清除所有数据,Google 不会提供其他选项来更改一旦选择的选项。
我该如何处理这种情况?有没有办法更改一旦选择的“从不”选项而不从应用程序中删除所有数据?
EDIT:
我在这里找到了解决方案:如何像谷歌地图一样显示启用位置对话框? https://stackoverflow.com/questions/29801368/how-to-show-enable-location-dialog-like-google-maps
我们需要添加到我们的构建器方法 setAlwaysShow (boolean show)
https://developer.android.com/reference/com/google/android/gms/location/LocationSettingsRequest.Builder.html#setAlwaysShow(boolean) https://developer.android.com/reference/com/google/android/gms/location/LocationSettingsRequest.Builder.html#setAlwaysShow(boolean)
LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
.addLocationRequest(mLocationRequestBalancedPowerAccuracy);
builder.setAlwaysShow(true);
之后我们只有两个选择——“是”和“否”。