Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android, how to determine if a reboot occurred?

Tags:

android

How would I programmatically determine when an android device has rebooted (whether on its own, or user initiated) ?

like image 843
NoCarrier Avatar asked Dec 03 '22 01:12

NoCarrier


1 Answers

Set up a BroadcastReceiver and register it in your manifest to respond to the android.intent.action.BOOT_COMPLETED system even. When the phone starts up the code in your broadcastreceiver's onReceive method will run. Make sure it either spawns a separate thread or takes less than 10 seconds, the OS will destroy your broadcastreceiver thread after 10 seconds.

like image 96
Aaron Bruce Avatar answered Dec 28 '22 11:12

Aaron Bruce