1

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.

nilkash
  • 7,408
  • 32
  • 99
  • 176

1 Answers1

3

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

Community
  • 1
  • 1
Daniel Nugent
  • 43,104
  • 15
  • 109
  • 137