Home Tags Archive
+ TWITTER Add to Google
Recent Articles

Android Boot Receiver

Authors : luigi agosti - Date : 01/11/2010 - Views : 7826
android boot receiver
Sometimes is useful to be able to intercept reboot events.

For example of you have to set up a service that run at different intervals using the AlarmManager You have to make sure to handle the reboot and reset the alarm because is lost otherwise.

So if you need to listen to reboot events in Android there is a simple way:

1. Add permission to RECEIVE_BOOT_COMPLETED
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
2. Add a receiver in the AndroidManifest.xml
<receiver android:name=".receiver.BootReceiver">
      <action android:name="android.intent.action.BOOT_COMPLETED"/>
3. Implement a receiver and do implements the necessary method.
public class BootReceiver extends BroadcastReceiver {
    public void onReceive(Context context, Intent intent) {