リブート後に保留中のインテントを継続するためにブロードキャストサービスを使用するアプリケーションがありますが、それが正常に動作しません。私の電話機を再起動すると、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:
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")){
Log.i("Xu", "Boot receiver is working");
}
をそして権限とカテゴリの意図を削除します。
@Override
public void onReceive(Context context, Intent intent) {
Log.i("Xu", "Boot receiver is working");
}
マニフェストで使用許可が2回宣言されているのはなぜですか?この 'android.intent.action.QUICKBOOT_POWERON'は何ですか?これはHTCにありますか? – t0mm13b
2つの異なる分野でそれらを使用した異なる例を見てきました。しかし、私はそれが動作していない理由は考えていません –
実際のブートレシーバクラスの[MCVE]の例を囲みます。ブロードキャストレシーバクラスのパッケージ全体が 'com.idkbro.pashchallenge.BootReceiver'であることを確認できますか? – t0mm13b