Zuhayr
Zuhayr

Reputation: 352

Enabled/disabled listener using FusedLocationApi?

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.

Upvotes: 3

Views: 527

Answers (1)

Bill
Bill

Reputation: 4646

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.

Upvotes: 2

Related Questions