The question is simple: For a location listener’s onProviderEnabled() method to be called when a specific provider is enabled, must that listener have already requested updates from that same provider?
For example, if you register for location updates with location manager from the network provider:
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0,
0, locationListener);
The listener has an onProviderEnabled() method:
@Override
public void onProviderEnabled(String provider) {
Log.d(TAG, provider + " provider enabled"); }
If I now turned on the GPS location provider, will onProviderEnabled be called?
From what I’ve experienced, no it is not called, unless the location listener was also registered to receive updates from the GPS provider. If it is supposed to be like this, then one would have to register with both the GPS and Network provider in order be notified that it was enabled.
Is it ok to register for updates from a location provider that is not yet enabled?
Yes, you need to register for a provider to be able to receive a callback from it.
It’s the action of registering with one provider, that informs that provider that a listener exists. If you don’t register with it, there is now way for it to know that a listener exists.
Yes.