location-samples icon indicating copy to clipboard operation
location-samples copied to clipboard

SETTINGS_CHANGE_UNAVAILABLE when locations are enabled

Open yankeppey opened this issue 8 years ago • 13 comments

Steps to reproduce:

  1. Enable Airplane mode (-> cell operator disabled)
  2. Disable Wi-Fi.
  3. Enable locations.
  4. Start "LocationSettings" example from this repositoty.

Expected result: LocationSettingsStatusCodes.SUCCESS or LocationSettingsStatusCodes.RESOLUTION_REQUIRED in onResult callback, because we're still able to receive updates for the same LocationRequest object.

Actual result: LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE. However, we still can requestLocationUpdates and receive them.

yankeppey avatar Mar 16 '16 19:03 yankeppey

Yes, I have the same problem!

Lomovskiy avatar Aug 24 '16 15:08 Lomovskiy

+1

gmarques33 avatar Aug 31 '16 22:08 gmarques33

I'm also struggling with this.

saket avatar Mar 17 '17 08:03 saket

+1

bnvinay92 avatar Mar 18 '17 10:03 bnvinay92

Same problem here. Looks like we won't get a fix anytime soon. Anybody has a good workaround to suggest?

aspyct avatar Apr 04 '17 13:04 aspyct

It seems you can still check for GPS and Network providers via the legacy LocationManager.

See below code (a bit specific, and Xamarin, but hey, you get the idea).

private IObservable<GoogleApiClient> ManualLocationCheck(GoogleApiClient client)
{
    Debug.WriteLine("Google can't tell us how to get location. Checking for ourselves");

    /*
    It looks like we can get a "Settings change unavailable" when the user
    is in airplane mode, but the location is enabled.
    So let's check whether location is enabled, because that's all we need.
    */
    var locationManager = (LocationManager)activity.GetSystemService(Context.LocationService);

    bool gpsEnabled;
    bool networkEnabled;

    try
    {
        Debug.WriteLine("Checking for GPS support");
        gpsEnabled = locationManager.IsProviderEnabled(LocationManager.GpsProvider);
    }
    catch (Exception e)
    {
        Debug.WriteLine(e);
        gpsEnabled = false;
    }

    try
    {
        Debug.WriteLine("Checking for network support");
        networkEnabled = locationManager.IsProviderEnabled(LocationManager.NetworkProvider);
    }
    catch (Exception e)
    {
        Debug.WriteLine(e);
        networkEnabled = false;
    }

    if (gpsEnabled || networkEnabled)
    {
        // Looks like we'll be able to get a location fix after all...
        OnUncertainLocationAvailability?.Invoke(new UncertainLocationAvailability
        {
            GpsEnabled = gpsEnabled,
            NetworkEnabled = networkEnabled
        });
        return Observable.Return(client);
    }
    else
    {
        // Nah, nothing we can do except ask the user to fix his settings
        throw new LocationNotAvailableException();
    }
}

aspyct avatar Apr 05 '17 17:04 aspyct

+1

nidhishah-rally avatar Jun 06 '17 00:06 nidhishah-rally

+1

rakuishi avatar Dec 25 '17 07:12 rakuishi

+1 It is hilarious that we need to use LocationManager as a backup

Rex1313 avatar Oct 04 '19 12:10 Rex1313

+1

dtunctuncer avatar Oct 10 '19 07:10 dtunctuncer

same happened to me :(

farmazon3000 avatar Apr 10 '20 18:04 farmazon3000

+1. Any answer from maintainers? Bug seems to be too easy to reproduce for not being fixed for 4 years.

igor-korotenko avatar May 27 '20 17:05 igor-korotenko

+1 Still having the same issue

rolfwessels avatar Oct 23 '20 10:10 rolfwessels