Remember to add the following permission:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
and add a receiver class entry in manifest.zml:
<receiver android:name="com.example.receivers.BootReceiver" >
Now the receiver class:
import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; public class BootReceiver extends BroadcastReceiver { private static final String TAG = "Boot Receiver:::"; @Override public void onReceive(Context context, Intent intent) { if (intent != null) { if (intent.getAction().equalsIgnoreCase( Intent.ACTION_BOOT_COMPLETED)) {
Now clean and run the application. Hope This class will be called up after turning the power on / off or restarting the device. Let me know your feedback.
Sivakumar
source share