我有一个具有 IntentFilter 和 BroadcastReceiver 的 Activity,我将它们注册到我的onCreate()
.
IntentFilter filter = new IntentFilter(ACTION_RCV_MESSAGE);
filter.addCategory(Intent.CATEGORY_DEFAULT);
receiver = new MessageReceiver();
registerReceiver(receiver, filter);
但是在结束我的应用程序时,Logcat 说:
07-03 01:38:19.567: ERROR/ActivityThread(304): android.app.IntentReceiverLeaked: Activity com.intentservicetest5.IntentServiceTest5Activity 泄露了最初在此处注册的 IntentReceiver com.intentservicetest5.IntentServiceTest5Activity$MessageReceiver@44efe8a8。您是否错过了对 unregisterReceiver() 的调用?
但我确实有
public void onDestroy(Bundle savedInstanceState){
unregisterReceiver(receiver);
}
为什么我打电话时我的活动仍然泄漏unregisterReceiver()
?