英文:
broadcast receiver gets unregistered on device reboot
问题
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package=""
android:installLocation="internalOnly">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true">
<receiver
android:name=".NotifReceiver"
android:enabled="true"
android:exported="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<activity
android:name=".MainActivity"
android:label=""
android:theme="@style/AppTheme">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
</application>
</manifest>
I have a broadcast receiver that should be triggered when the device is booted, but it never gets triggered when the device is booted. Instead, the whole broadcast receiver gets unregistered. I know this issue has been asked about multiple times before, but none of the solutions seem to work.
Thanks in advance.
Edit: I am using API 19.
英文:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="" android:installLocation="internalOnly">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
>
<receiver
android:name=".NotifReceiver"
android:enabled="true"
android:exported="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<activity
android:name=".MainActivity"
android:label="" android:theme="@style/AppTheme">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
</application>
</manifest>
i have a broadcast receiver which should be triggered when device is booted but it never gets triggered
when device is booted instead the whole broadcast receiver gets unregistered
.i know this has been asked multiple times before but none of the solutions seem to work
thanks in advance
edit : i am using api 19
答案1
得分: 0
Remove android:permission="android.permission.RECEIVE_BOOT_COMPLETED"
from your <receiver>
element.
英文:
Remove android:permission="android.permission.RECEIVE_BOOT_COMPLETED"
from your <receiver>
element.
专注分享java语言的经验与见解,让所有开发者获益!
评论