android - 广播接收器没有获得 MY_PACKAGE_REPLACED Intent

标签 android android-intent android-8.0-oreo

根据 Android O 开发者预览版,我们不能再使用 PACKAGE_REPLACED Intent 与 list 中声明的​​接收器一起使用。

替代方案是 MY_PACKAGE_REPLACED。但是当我在代码更改后通过 android studio 更新应用程序时,这个 Intent 似乎并没有触发。而旧的更广泛的 Intent 总是正确触发。

    <receiver
        android:name=".Receivers.BootEventReceiver"
        android:exported="true"
        android:enabled="true">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
        </intent-filter>
    </receiver>

假设接收器本身只是在 onReceive() 中打印一条日志消息。

谷歌搜索表明这似乎是一些 android list 合并问题。但我真的不知道如何解决这个问题。

谁能给我指出正确的方向

最佳答案

我决定用 MY_PACKAGE_REPLACED Intent 过滤器制作一个单独的接收器,而不是让一个接收器带有两个 Intent 过滤器。

接收器再次开始工作。希望这可以帮助任何感兴趣的人

关于android - 广播接收器没有获得 MY_PACKAGE_REPLACED Intent ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43006134/

相关文章:

java - OutOfMemoryError 消息的清晰解释

android - 媒体编解码器 : MediaFormat setting KEY_I_FRAME_INTERVAL value is ignored

Android sqlite更新行

java - 有没有办法通过 Intent 或其他方式共享 *.json 文件?

java - 来自原生的 Android O 设备序列号

android - Tab 键在 Android Studio 中不起作用

android - 如何在通知点击时重新启动/刷新 Activity 内容

java - 放在 Intent/bundle 中的一些 Parcelables 对象可能会 self 干扰并影响 Intent/Bundle 的读取?

android - 如何在 Android 8 上获得广播 ACTION_POWER_CONNECTED

安卓 O | API 级别 26 或 27