Android:为什么我没有收到 BOOT_COMPLETED Intent ?

标签 android broadcastreceiver boot intentfilter

我正在物理设备上进行测试 (SAMSUNG ACE GT S5830i)

但我没有收到 BOOT_COMPLETED Intent ,因此服务不是 Receiver 未启动

这是我正在使用的代码。

public class BootCompleteReceiver extends BroadcastReceiver {
static final String TAG = "InfoService.BroadcastReceiver";

@Override
public void onReceive(Context context, Intent intent) {
  if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
    Log.e(TAG, "System boot notification received.");
    Intent service = new Intent(context, InfoService.class);
    context.startService(service);
  } else {
    Log.e(TAG, "Intent received: " + intent);
  }
}
}

这是 list

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.appengine.paranoid_android.lost"
  android:versionCode="2"
  android:versionName="1.1">
<application android:icon="@drawable/ic_launcher"
        android:label="@string/app_name">
    <activity android:name=".InfoSetup"
              android:label="@string/activity_name"
              android:launchMode="singleTask"
              android:clearTaskOnLaunch="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".LockScreen"
              android:label="@string/activity_name"
              android:launchMode="singleInstance"
              android:clearTaskOnLaunch="true"
              android:theme="@android:style/Theme.NoTitleBar">
    </activity>

    <service android:name=".InfoService"
        android:label="@string/service_name"/>

    <receiver android:name=".BootCompleteReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED"/>
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.PACKAGE_ADDED"/>
            <action android:name="android.intent.action.PACKAGE_CHANGED"/>
            <action android:name="android.intent.action.PACKAGE_REMOVED"/>
            <data android:scheme="package"/>
        </intent-filter>
    </receiver>
</application>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<!-- <uses-permission android:name="android.permission.DISABLE_KEYGUARD"/> -->

最佳答案

尝试为 <receiver android:name=".BootCompleteReceiver"> 添加包的完整路径

<receiver android:name="com.appengine.paranoid_android.lost.BootCompleteReceiver">

关于Android:为什么我没有收到 BOOT_COMPLETED Intent ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16691806/

相关文章:

ubuntu - 命令未在 etc/rc.local ubuntu 中运行

android - 使用 C2DM 开发时的未知权限

android - Google Play 应用评论和规范

android - 如何在 Eclipse for Android 中更改 Control+Space 自动完成快捷键

android - 如何让 Android BroadcastReceiver 与 AlarmManager 配合使用?

containers - 如何在启动时在boot2docker中自动启动容器?

java - 如何从对话框 fragment 打开新 Activity

android - WhatsApp后台运行系统

Android连接更改广播顺序

c - 引导加载程序上的图形