在Android O中使用意图广播USER_PRESENT [英] Using intent broadcast USER_PRESENT in Android O

查看:136
本文介绍了在Android O中使用意图广播USER_PRESENT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于O加强了后台服务,因此在定位26岁以上的用户时,如何接收USER_PRESENT的广播?

Since O is more enforcing background services, how can I receive a broadcast of USER_PRESENT when targeting 26+ ?

Logcat:

system_process W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.USER_PRESENT flg=0x24200010 } to fr.cab13140.nullcontactdeleter/.BootThread

推荐答案

接收广播的唯一方法是运行一个进程,在该进程中,您已使用 registerReceiver()注册接收器.如果您一直尝试收听此广播,则获得的最接近的服务将是前台粘性服务,以最大程度地延长服务运行的时间.请注意,用户可能不会对此感到满意.

The only way to receive that broadcast is by having a running process, where you have used registerReceiver() to register your receiver. If you are trying to listen to this broadcast all of the time, the closest that you will get will be to have a foreground sticky service, to try to maximize the amount of time your service is running. Note that users may not appreciate this.

这篇关于在Android O中使用意图广播USER_PRESENT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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