【已解决】 求助!在公司给的安卓屏上接收不到开机广播。
ManiFest代码:
<receiver
android:name=".service.MainReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
Java代码:
@Override
public void onReceive(final Context context, Intent intent) {
//判断收到的是什么广播
String action = intent.getAction();
if (action.equals(action_boot)) {
Log.d(TAG, "MainReceiver||===收到开机广播");
Toast.makeText(context, "收到开机广播", Toast.LENGTH_LONG).show();
AppUtils.reStartApp(context, 2000, false);
} else {}
Log:

第一个是为什么要加category呢?只有action范围限定不是更广一点吗?
第二个是你好自信哦,你为什么不把action打出来呢?万一你的action_boot写错了呢?再说了,你都知道android.intent.action.BOOT_COMPLETED这个了,你不会用Intent里的常量吗?
第三个就是权限添加一下,如果还不行,就告诉一下我们你的是什么手机。