nilkash
nilkash

Reputation: 7536

isProviderEnabled always return true for network provider

Hi I am developing small android application in which I am trying to check whether network provider enabled or not. If not then look for GPS provider. But in my case for network provider always returns true.I tried to check that in following manner

    if (locManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
getLastLocation(LocationManager.NETWORK_PROVIDER);

} else if (locManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0, this);
getLastLocation(LocationManager.GPS_PROVIDER);
}

In above code network provider always return true. Even I don't have any network provider. Is there anything wrong I am doing? Need some help. Thank you.

Upvotes: 1

Views: 2285

Answers (1)

Daniel Nugent
Daniel Nugent

Reputation: 43322

In order for Network Location to be disabled, you must either set your Location Mode to off, or GPS only.

So, for isProviderEnabled(LocationManager.NETWORK_PROVIDER) to return false, it will either need to look like this (completely disabled):

enter image description here

Or this (Location enabled, GPS only):

enter image description here

To see what it looks like on KitKat, see here: https://stackoverflow.com/a/30580898/4409409

Upvotes: 3

Related Questions