1

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!! :)

Price
  • 2,683
  • 3
  • 17
  • 43

2 Answers2

0

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.

Community
  • 1
  • 1
mrek
  • 1,655
  • 1
  • 21
  • 34
  • 1
    Nope, they are using the latest version (7.0) of Google Play Services library. I just checked in my android SDK and it is available to the general public now! – iceman Mar 20 '15 at 14:24
  • The link to "this answer" does not link to the answer. It links to the image on imgur. Could you please fix the link? – Martin Ackermann Apr 14 '15 at 07:30
0

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

iceman
  • 826
  • 13
  • 25