(this is about the LocationManager
class in android).
Is there a way of using requestLocationUpdates
, but in some way that allows it to give me results for the best active provider every time? I could pass it the result of getBestProvider
, but then it will always return results from that provider, and it wouldn't work as I expect if the user turns the gps on/off.
My code is in a background service.
This is what I do:
From API level 9 and onwards, this is possible, using this method:
See the documentation for more information on usage.
No, though you are welcome to register separate
LocationListeners
for multiple providers.Your
LocationListener
is notified when its provider is enabled and disabled. If your current provider is disabled, you might register aLocationListener
with a backup provider.