android.intent.action.BOOT_COMPLETED Intent is not received at “Restart” or “Reboot”

三世轮回 提交于 2019-11-30 08:55:56

Add

<action android:name="android.intent.action.QUICKBOOT_POWERON" /> 

also

Kindly add the below Permission:

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

and add the Receiver Class entry in manifest.zml:

<receiver android:name="com.example.receivers.BootReceiver" >

Now 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:::";
   /*
    * (non-Javadoc)
    * 
    * @see android.content.BroadcastReceiver#onReceive(android.content.Context,
    * android.content.Intent)
    */
    @Override
    public void onReceive(Context context, Intent intent) {
      if (intent != null) {
        if (intent.getAction().equalsIgnoreCase(
                Intent.ACTION_BOOT_COMPLETED)) {

            //Boot Receiver Called
        }
      }
    }
 }

Now Clean and Run your Application. Hope This class will be called after you power on/off or restarting the device. let me know your feedback.

Add <action android:name="android.intent.action.QUICKBOOT_POWERON" /> this permission in manifest file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!