1

I'm trying to enable the location from application using Settings API. In location dialog it shows message Use WiFi and cellular networks for location. On selection of Yes it is enabling the location but not the GPS.

This is what I get

But while I was playing with Google Maps in same device, it displays the message Use GPS, WiFi and cellular networks for location as like below screenshot.

And this is enabling the GPS also. How can I achieve the same as Google Maps.

Before posting here I hope I have checked all the possible options. Find my tryouts list below.

I have set the priority as HIGH_ACCURACY and min interval to 5 seconds

locationRequest = LocationRequest.create();

// Set the priority of the request
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

// Set the update interval to 10 seconds
locationRequest.setInterval(1000 * 10);

// Set the fastest update interval to 5 seconds
locationRequest.setFastestInterval(1000 * 5);

Using only FINE_LOCATION permission

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

Also referred few links but nothing gave exact solutions. All I need is I would like to enable the location with HIGH_ACCURACY by default which enables the GPS Any help on this?

Community
  • 1
  • 1
Kavin Prabhu
  • 2,307
  • 2
  • 17
  • 36
  • That is strange, it seems as though it should work as-is. Take a look at the answer here: http://stackoverflow.com/a/31816683/4409409 – Daniel Nugent Aug 11 '16 at 15:18

1 Answers1

1

I had this problem, but after clicking the YES button to permit use GPS, the activity stops and runs the method onPause and then the activity begins in the method onResume. So my solution was start again the localizacion in onResume method

@Override onResume public void () {

         //your code
         LocationRequest = LocationRequest.create ();

         // Set the priority of the request
         locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

         // Set the update interval to 10 seconds
         locationRequest.setInterval (1000 * 10);

         // Set the fastest update interval to 5 seconds
         locationRequest.setFastestInterval (1000 * 5);
         .....
         //start again the localizacion 
         LocationServices.FusedLocationApi.requestLocationUpdates(apiClient, locRequest, this);
Jorge T
  • 121
  • 1
  • 2
  • 9