当前位置: 萬仟网 > IT编程>移动开发>Android > MTK FAQ-Android O版本发送广播受限问题

MTK FAQ-Android O版本发送广播受限问题

2019年05月28日 07:21  | 萬仟网IT编程  | 我要评论

android o版本对后台进程做了限制广播的发送,对隐式广播也做了限制;
隐式广播发送:
sendbroadcast(new intent("android.intent.action.my_broadcast_test2"));
制定组件然后发送:
intent mintent=new intent(broadcasttestactivity.this,myreceiver.class);
mintent.setaction("android.intent.action.my_broadcast_test2");
sendbroadcast(mintent);
[solution]
o版本:
(1)
配置targetsdkversion<=25
sendbroadcast(new intent("android.intent.action.my_broadcast_test2"));
app处于前台,可以正常发送;
(2)
配置targetsdkversion>=26
intent mintent=new intent(broadcasttestactivity.this,myreceiver.class);
mintent.setaction("android.intent.action.my_broadcast_test2");
sendbroadcast(mintent);
app处于前台,可以正常发送;
(3)
配置targetsdkversion>=26
sendbroadcast(new intent("android.intent.action.my_broadcast_test2"));
前台、后台发送受限;
log如下:
01-02 00:49:35.317 916-1039/system_process w/broadcastqueue: background execution not
allowed: receiving intent { act=android.intent.action.my_broadcast_test2 flg=0x10 } to
com.mtk14456.myapplication/.myreceiver
(4)
应用处于后台时,发送广播会受限;参考官方文档;
https://developer.android.com/about/versions/oreo/android-8.0-changes#back-all

文章选自“http://bbs.16rd.com/thread-474487-1-1.html”,转载请注明出处

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

◎已有 0 人评论

Copyright © 2019  萬仟网 保留所有权利. 粤ICP备17035492号-1
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com