一、 android.content.ReceiverCallNotAllowedException: IntentReceiver components are not allowed to register to receive intents解决方法:
在Android开发中
1、bindService不能在BroadcastReceiver 中调用,你可以在里面调用StartService并把要传递参数放到intent中
2、registerReceiver不能在BroadcastReceiver调用,可以通过context.getApplicationContext().registerReceiver();解决,我测试成功
其他的android.content.ReceiverCallNotAllowedException也可以通过context.getApplicationContext(),不过我没有测试。
本文探讨了在Android应用开发中遇到的ReceiverCallNotAllowedException错误,并提供了两种有效的解决方案:避免在BroadcastReceiver中使用bindService方法,而是通过StartService和intent传递参数;以及在BroadcastReceiver中使用context.getApplicationContext().registerReceiver()方法来注册接收器。

729

被折叠的 条评论
为什么被折叠?



