2

Is there a way to be notified when the GPS is switched on/off?

I noticed that when the device is switched off an then on again, getLastKnownLocation(provider) is null. So I want to save the location when the GPS is switched off to a database.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
robasta
  • 4,621
  • 5
  • 35
  • 53

1 Answers1

5

Register a BroadcastReceiver to listen for the LocationManager's PROVIDERS_CHANGED_ACTION Intent. This will be broadcast when the GPS provider (and other providers) is enabled / disabled.

Sam
  • 86,580
  • 20
  • 181
  • 179