在Android 8中注册BOOT_COMPLETED接收器 [英] Registering BOOT_COMPLETED receiver in Android 8

查看:533
本文介绍了在Android 8中注册BOOT_COMPLETED接收器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们将更新我们的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆