Android广播接收器注册问题:Caused by: java.lang.IllegalArgumentException: Receiver not registered

1、程序中明明使用如下方法进行了广播的注册和解除注册:

mContext.registerReceiver(downloadReceiver, filter);
mContext.unregisterReceiver(downloadReceiver);

但程序运行过程中还是有一下问题:

android.app.IntentReceiverLeaked: Activity *********** has leaked IntentReceiver *********** that was originally registered here. Are you missing a call to unregisterReceiver()?

并出现报错:

Caused by: java.lang.IllegalArgumentException: Receiver not registered: ***************

后来改成下面方法就可以了:

mContext.getApplicationContext().registerReceiver(downloadReceiver, filter);
mContext.getApplicationContext().unregisterReceiver(downloadReceiver);


文章来自:http://blog.csdn.net/heqiangflytosky/article/details/42527561
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3