location-samples
location-samples copied to clipboard
SETTINGS_CHANGE_UNAVAILABLE when locations are enabled
Steps to reproduce:
- Enable Airplane mode (-> cell operator disabled)
- Disable Wi-Fi.
- Enable locations.
- 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.
Yes, I have the same problem!
+1
I'm also struggling with this.
+1
Same problem here. Looks like we won't get a fix anytime soon. Anybody has a good workaround to suggest?
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();
}
}
+1
+1
+1 It is hilarious that we need to use LocationManager as a backup
+1
same happened to me :(
+1. Any answer from maintainers? Bug seems to be too easy to reproduce for not being fixed for 4 years.
+1 Still having the same issue