问题描述

环境是:API32,最小SDK26,

发送广播,本App都无法接收,日志出现错误:
background execution not allowed: receiving Intent { act=hello flg=0x10 (has extras) } to com.example.brocast_page/com.example.reciver.MyReciver

原因分析

target>=26时,APP发送的静态广播连自己也收不到

问题解决

对于隐式广播,如果没有包含FLAG_RECEIVER_INCLUDE_BACKGROUND不允许被接收,而源码中,提供的该字段为
在这里插入图片描述
所以自行添加

intent.addFlags(0x01000000);
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐