简体   繁体   中英

Google Play Services LocationServices.API - new option “never”

SOLVED - ANSWER AT THE END

I'm using new way to retrieve location from Google Play Services 7.0:

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

On the beginning, it gives us only two options, "Cancel" and "Turn on" (picture below).

在此输入图像描述

But today I saw new "feature" with new update of Google Play Services - when my location is turned off and try to get it via Google Play Services, popped dialog gives me options:

在此输入图像描述

Yes, NEVER. When I clicked it, my app will NEVER get location via Google Play Services, even if it's on and I have no other option but re-install app or clear all data, Google gives no other options to change once selected option.

How can I handle this situation? Is there any way to change once selected "never" option without deleting all data from application?

EDIT:

I've found the solution here: How to show enable location dialog like Google maps?

We need add to our builder method setAlwaysShow (boolean show)

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);

After that we have only two options - "Yes" and "No".

You can clear the default settings from

Settings -> Application manager -> Click Google Play Services -> Click Clear defaults

This will clear your preference previouls selected as never

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM