I have an application that uses a Network provider for its location. Every time the apps starts it checks to see whether the Network provider is enabled using
isProviderEnabled() method in LocationManager.
If it returns false I present an alert to the user to enable Network Provider and then use the application. This logic had been working really well, with a few exceptions with non-Google certified devices(not a concern since they usually do not have Maps API either). Lately, with some devices on ICS and now on JellyBean emulator, I get a consistent “false” for
isProviderEnabled() even though it is enabled.
I have since moved to use the string returned from
Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED)) to see whether it contains “network”. It is a hack but it is working for now. I would love to be able to use
Has anyone seen this issue before?
From the API doc for : LocationManager.GPS_PROVIDER
This provider determines location using satellites. Depending on
conditions, this provider may take a while to return a location fix.
Requires the permission ACCESS_FINE_LOCATION.
So if you’re not requiring ACCESS_FINE_LOCATION it will return false.
I also noticed this issue where
isProviderEnabled(LocationManager.GPS_PROVIDER) was returning
Solution to this is to also ask user to set the
Location Method to
High Accuracy instead of
Battery Saving or
This setting is available under location settings and has different name on different devices. On some devices that I have tested on, this setting is with name
Location Method etc Also the value can be
High Accuracy or
GPS, Wifi and Mobile Networks
Developers will have to train users on this.