Reputation: 2703
I am using Google Play Location Service to get location updates with high accuracy in my Android app as follows:
mLocationRequest=LocationRequest.create();
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
My question is that if the app user has selected the battery saving location mode (see below image) in the device settings, then would the above request be able to get location updates with high accuracy or would I have to toggle the location mode programmatically? Or is getting the user change the location mode manually the only solution?
As always, many thanks to everyone helping out to point in the right direction!! :)
Upvotes: 1
Views: 1342
Reputation: 1888
According to this article, you cannot do that without superuser rights. However, Google Maps has this functionality, because it is a system (built-in) app:
Fortunately, (as iceman mentioned), if you have the latest version of Google Play services (7.0), you can use Location Settings Dialog.
You can find more information here.
Upvotes: 0
Reputation: 826
No, you can't change the user's location preference programatically. The user's preference overrides your LocationRequest
priority and the permissions in your manifest file.
The best solution is to use a new API in the Google Play Services 7.0 lib which allows you to create the dialog (not directly but play services creates it for you) seen the screenshot in @mrek 's answer. You have to use a LocationSettingsRequest.Builder
(reference).
Upvotes: 0