Price
Price

Reputation: 2703

Is it possible to get location updates on Android with high accuracy if the user has selected battery saving location mode on their device?

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?

Battey saving setting for location mode on Android

As always, many thanks to everyone helping out to point in the right direction!! :)

Upvotes: 1

Views: 1342

Answers (2)

mrek
mrek

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:

enter image description here

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

iceman
iceman

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

Related Questions