在Android 8中注册BOOT

编程入门 行业动态 更新时间:2024-10-26 14:29:00
本文介绍了在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.

developer.android/guide/components/broadcast- exceptions.html

无需更改任何内容.确保您在Android 8中进行测试.

No need to change anything. Make sure you test in Android 8.

更多推荐

在Android 8中注册BOOT

本文发布于:2023-11-27 10:34:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637719.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Android   BOOT

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!