I want to select a LocationProvider that is enabled in Android. The project build target is Android 2.1.
This is what I do in onCreate().
// ...
LocationManager locationMgr = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.NO_REQUIREMENT);
criteria.setPowerRequirement(Criteria.NO_REQUIREMENT);
criteria.setCostAllowed(false);
String bestProvider = locationMgr.getBestProvider(criteria, true);
Toast.makeText(getApplicationContext(), "Provider = " + bestProvider + " enabled= " + locationMgr.isProviderEnabled(bestProvider), Toast.LENGTH_LONG).show();
// ...
Now, I switch each network interface off and set flight mode on my device (HTC Desire, Android 2.2). I disconnect the device from USB. There is clearly no provider alive who could actually provide location data to the device. I specifically ask getBestProvider for enabled providers only, so I expect it to return null or an empty string in that case. I expect isProviderEnabled to return false.
The actual result is that getBestProvider returns "network" and isProviderEnabled reports it to be "enabled". Is "network" always "enabled" even when its not?