在Android 8中注册BOOT_COMPLETED接收器 [英] Registering BOOT_COMPLETED receiver in Android 8
问题描述
我们将更新我们的App Android API26.在有关广播接收器说
We are about to update our App Android API 26. In the documentation about Broadcast receiver it says that
面向Android 8.0或更高版本的应用无法再在其清单中为隐式广播注册广播接收器
Apps that target Android 8.0 or higher can no longer register broadcast receivers for implicit broadcasts in their manifest
隐式广播接收器描述为
未专门针对该应用的广播.例如,ACTION_PACKAGE_REPLACED
a broadcast that does not target that app specifically. For example, ACTION_PACKAGE_REPLACED
所以我认为android.intent.action.BOOT_COMPLETED
被视为隐式接收器.
So I assume that android.intent.action.BOOT_COMPLETED
is considered an implicit receiver.
此外,它指出必须使用Context.registerReceiver()
在Activity
中注册隐式接收者.但这对于正在监听BOOT_COMPLETED
事件的接收者来说毫无意义.
Further it states that implicit receivers must be registered within an Activity
by using Context.registerReceiver()
. But that wouldn't make sense for a receiver, which is listening for the BOOT_COMPLETED
event.
处理此问题的正确方法是什么?我可以把这个接收器放在清单上吗?
What is the proper way to handle this? Can i keep this receiver in my manifest?
推荐答案
BOOT_COMPLETED仍被接受.
BOOT_COMPLETED is still accepted.
https://developer.android.com/guide/components/broadcast- exceptions.html
无需更改任何内容.确保您在Android 8中进行测试.
No need to change anything. Make sure you test in Android 8.
这篇关于在Android 8中注册BOOT_COMPLETED接收器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!