Android BOOT_COMPLETED Broadcast Receiver Usage

by Sasikumar 2014-03-11 12:50:10

Android BOOT_COMPLETED Broadcast Receiver:
Step 1: Declare permission in android manifest file as
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

Step 2: Register the Broadcast Receiver in the manifest file as
<receiver android:name=".BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>

Step 3: Class that handles the Broadcast should extend the BroadcastReceiver. onReceive() function in the BroadcastReceiver will be executed when the BOOT_COMPLETED signal is Broadcasted.
public class BootReceiver extends BroadcastReceiver
{
public void onReceive(Context context, Intent intent)
{
Toast.makeText(context, "Boot Process Completed", Toast.LENGTH_LONG).show();
}
}
Here when the device boot is completed a Toast with the message "Boot Process Completed" will be displayed on the screen.
894
like
0
dislike
0
mail
flag

You must LOGIN to add comments