Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

SETTINGS_CHANGE_UNAVAILABLE when locations are enabled #47

Open
yankeppey opened this issue Mar 16, 2016 · 13 comments
Open

SETTINGS_CHANGE_UNAVAILABLE when locations are enabled #47

yankeppey opened this issue Mar 16, 2016 · 13 comments
Labels
migrated googlesamples Migrated from old googlesamples repos

Comments

@yankeppey
Copy link

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.

@Lomovskiy
Copy link

Yes, I have the same problem!

@gmarques33
Copy link

+1

@saket
Copy link

saket commented Mar 17, 2017

I'm also struggling with this.

@bnvinay92
Copy link

+1

@aspyct
Copy link

aspyct commented Apr 4, 2017

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

@aspyct
Copy link

aspyct commented Apr 5, 2017

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();
    }
}

@nidhishah-rally
Copy link

+1

1 similar comment
@rakuishi
Copy link

+1

@Rex1313
Copy link

Rex1313 commented Oct 4, 2019

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

@dtunctuncer
Copy link

+1

@farmazon3000
Copy link

same happened to me :(

@igor-korotenko
Copy link

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

@rolfwessels
Copy link

+1 Still having the same issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
migrated googlesamples Migrated from old googlesamples repos
Projects
None yet
Development

No branches or pull requests