I wrote the code below, but it\'s not working. Can anybody help me? I just want to passively receiving GPS status changes, rather than proactive inquiries. Saving power is m
I believe you are simply pointing to the wrong location in the manifest, change the receiver's name:
<receiver android:name=".GPStStatusReceiver">
This type of receiver is great for starting an app whenever the GPS is enabled, but while the app is running the LocationListener's onProviderEnabled() or onProviderDisable() will catch these even if the refresh interval is set to 10 days and a 1000 miles, or more. So you will not necessarily waste battery power if you pass generous settings to the requestLocationUpdates() method.
Addition from comments
I can only guess that you are not receiving the GPS_ENABLED_CHANGE
because you are not triggering a location request. Simply enabling the GPS feature by clicking the checkbox in the Locations menu will not broadcast this Intent, some app must request the current location. Also, I didn't find any official documentation on this Intent which means Android might change or remove this at any time.
Perhaps you want the officially supported LocationManager.PROVIDERS_CHANGED_ACTION, this will broadcast an Intent when the GPS provider (and other providers) is enabled / disabled.
<action android:name="android.location.PROVIDERS_CHANGED" />