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
  • 31,815
  • 47
  • 169
  • 296
robasta
  • 4,557
  • 5
  • 34
  • 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
  • 85,827
  • 19
  • 179
  • 175