Android广播限制Background execution not allowed: receiving Intent { act=

“Background execution not allowed: receiving Intent”这个错误信息通常出现在Android应用开发中,特别是在处理后台任务或接收广播(Broadcast)时。这个错误表明应用试图在后台执行某些操作,但Android系统出于电池优化和用户体验的考虑,限制了后台任务的执行。

可以尝试以下二种方法:

1.把targetSdkVersion设置为25及以下的版本号,重新编译

Android系统限制:从Android 8.0(API26)开始,Android系统对后台任务的执行进行了更严格的限制。这些限制旨在减少不必要的后台活动。

降低SDK,需要相应的调整dependencies,类,属性及资源

广播接收方降低即可

//noinspection ExpiredTargetSdkVersion
targetSdkVersion 24
2.静态广播修改为动态广播。如果应用需要接收广播,可以考虑使用动态注册的广播接收器(在Activity或Service中注册),而不是在AndroidManifest.xml中静态注册。动态注册的接收器在组件销毁时会自动取消注册,从而避免不必要的后台活动。

MyReceiver myReceiver = new MyReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("com.action.url");
registerReceiver(myReceiver, intentFilter);

Background execution not allowed,广播无法接收原因及解决方法_background execution not allowed: receiving intent-CSDN博客

Android广播限制Background execution not allowed: receiving Intent { act=-CSDN博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xiaowang_lj

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值