The regular Android (non-Fused) LocationListener
https://developer.android.com/reference/android/location/LocationListener.html
has the methods onProviderEnabled
and onProviderDisabled
,
so that you can listen for when the user turns off/on the GPS. In the Fused version
https://developers.google.com/android/reference/com/google/android/gms/location/LocationListener
there is only onLocationChanged
.
I'm wondering how to determine when my user turns GPS/location on/off while using the Fused Location API.
Note that this is different from wanting to query once and receive a boolean whether location is enabled or disabled; I need a listener that has a callback to take action upon a change.
Thanks a lot in advance for any help.
LocationAvailability is probably what you are looking for.
When you call requestLocationUpdates
, one of the parameters is a LocationCallback
which gives you access to the listener onLocationAvailability
.