简体   繁体   English

广播接收器在设备重启时取消注册

[英]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>

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编辑:我正在使用 api 19

Remove android:permission="android.permission.RECEIVE_BOOT_COMPLETED" from your <receiver> element.<receiver>元素中删除android:permission="android.permission.RECEIVE_BOOT_COMPLETED"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 引导/广播接收器重新引导问题 - Boot/Broadcast Receiver reboot issues 广播意图回调被取消,并导致设备取消注册 - Broadcast intent callback is cancelled and causes device to be unregistered 重新启动android后广播接收器不起作用 - Broadcast Receiver not working after reboot android 广播接收器在某些设备上使应用程序崩溃 - Broadcast receiver crashing the app in some device Android已连接设备电源而没有广播接收器 - Android is device power connected without broadcast receiver 当应用程序在 android 版本 9 中被杀死时收听呼叫广播接收器 - listen to call broadcast receiver when app gets killed in android version 9 广播接收器收到消息后,更新recyclerview上的切换按钮 - Update the toggle button at recyclerview when the broadcast receiver gets the message 应用被杀死时,广播接收器未在Oreo上收听 - Broadcast receiver not listening on Oreo when app gets killed Android:每次重新启动/链中的下一个SMS时,未读短信都会触发SMS接收器的广播意图 - Android: SMS receiver broadcast intent is triggered by unread sms'es at each reboot / at next SMS in chain 通过广播接收器以编程方式连接Android中的蓝牙设备 - Programmatically connect Bluetooth Device in Android from Broadcast Receiver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM