gpt4 book ai didi

java - 泄露的 IntentReceiver

转载 作者:行者123 更新时间:2023-11-29 21:20:59 31 4
gpt4 key购买 nike

我的 onCreate() 中有以下代码:

registerReceiver(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));

此行似乎引发了以下错误:Activity 泄露了最初在此处注册的 IntentReceiver。您是否错过了对 unregisterReceiver() 的调用?

不过我只是不明白这是怎么可能的 - 我完全卸载了我的应用程序然后重新安装它,这是整个应用程序中唯一的接收器注册。有谁知道出了什么问题吗?

最佳答案

您需要在 onPause 中注销您的接收器:

@Override
protected void onPause() {
// Unregister since the activity is not visible
LocalBroadcastManager.getInstance(this).unregisterReceiver(onComplete);
super.onPause();
}

关于java - 泄露的 IntentReceiver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20734593/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com