1

I have an re-occurring alarm manager task that needs to run nightly, However when the device is turned off then back on, it erases this task and I have no way to reset it. I would like to know how to tell if a device has been turned off and/or if you can run specific code before the phone turns off so I can set a flag to reset this task.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
ninjasense
  • 13,756
  • 19
  • 75
  • 92

1 Answers1

6

Register for the RECEIVE_BOOT_COMPLETED permission and set up a BroadcastReceiver to watch for BOOT_COMPLETED broadcasts.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491