0

I am trying to get notifications when the user enables/disables location services. I know that I can do this by using the android.location.LocationManager API

https://developer.android.com/reference/android/location/LocationManager#MODE_CHANGED_ACTION

or

https://developer.android.com/reference/android/location/LocationManager#PROVIDERS_CHANGED_ACTION

But I cannot find an equivalent using the Google Play Services location API.

I can use checkLocationSettings to see the current settings and display a dialog to resolve them if necessary. But without the option to register a receiver/listener, I have to write a polling loop for this call, which is a lot of wasted effort.

The package summary for android.location https://developer.android.com/reference/android/location/package-summary says:

The Google Location Services API, part of Google Play services, is the preferred way to add location-awareness to your app. It offers a simpler API, higher accuracy, low-power geofencing, and more.

So surely there should be a simpler API to get programmatic notifications of location services enable/disable using Google Location Services than the default android.location.LocationManager?

What am I missing here?

Shankari
  • 389
  • 2
  • 4
  • 14
  • Have you checked this related [SO post](https://stackoverflow.com/questions/44691894/how-to-disable-the-broadcast-receiver-to-stop-receiving-the-incoming-calls)? – Jessica Rodriguez Feb 19 '19 at 13:26
  • I don't think that is very related. First, it is related to phone calls and not to location tracking (e.g. `android.intent.action.PHONE_STATE`). And second, it looks like the OP wants to disable a broadcast receiver registered in the manifest based on a switch in their activity (i.e. `DashboardActivity`). In my case, I want to (always) receive notifications of user changes directly to the location settings in the settings app. – Shankari Feb 19 '19 at 23:09

0 Answers0