In Android OS, in "Settings" --> "Location services", there is a toggle button named "Access to my location" which can be used to disable & enable location info access from apps.
Currently, I am developing a location service application. I am wondering, how can I listen to this setting in my Android project? Is there any broadcast receiver I can use to know right away when user disable or enable "Access to my location" ?
If there isn't any broadcast receiver for it, how can I listen to this change in my Android project?
This works for me:
Add receiver to the Manifest file:
Check both location providers in receiver:
Though this receiver is called more than once due to obvious reasons, but this will tell you the status.
You can use the below code to check whether Location Service Enable or not
You can do it much simpler this way. In your BroadcastReceiver's onReceive() method:
~Thanks to this code: LocationManagerTest.java