我有一个应用程序,使用广播服务来重新启动后继续我的未决意图,但它没有按照它应有的工作。在我重新启动手机后,我弹出通知MyAppsName has stopped working
。我为它制作的日志没有出现。Android:引导广播重新启动后不工作
的manifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.idkbro.pashchallenge">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<application
android:allowBackup="true"
android:name=".BaseApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<receiver android:name=".AlertReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
<receiver
android:name=".BootReceiver"
android:enabled="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<service
android:name=".NotificationService"
android:exported="true"></service>
</application>
的BootReceiver:
@Override
public void onReceive(Context context, Intent intent) {
Log.i("Xu", "Boot receiver is working");
}
为什么在清单中声明了两次权限?这是什么'android.intent.action.QUICKBOOT_POWERON'?这是在HTC吗? – t0mm13b
不是我见过不同的例子,使用它们在2个不同的领域。但我不认为这就是为什么它不起作用 –
请附上一个实际启动接收器类的[MCVE]示例。你可以确认广播接收器类的完整包是'com.idkbro.pashchallenge.BootReceiver'? – t0mm13b