Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android LocationManager.isProviderEnabled() always returns false

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 isProviderEnabled() method.

Has anyone seen this issue before?

like image 958
naqi Avatar asked Jul 11 '12 16:07

naqi


1 Answers

@naqi @gkris I also noticed this issue where isProviderEnabled(LocationManager.GPS_PROVIDER) was returning false.
Solution to this is to also ask user to set the Location Method to High Accuracy instead of Battery Saving or Device Only

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 Mode, Location Mode, Location Method etc Also the value can be High Accuracy or GPS or GPS, Wifi and Mobile Networks

Developers will have to train users on this.

like image 78
Ashish Pathak Avatar answered Nov 11 '22 15:11

Ashish Pathak