01-16 16:52:42.211: E/ActivityThread(2529): Activity com.Civilcourage.CivilcurageSplash has leaked IntentReceiver com.google.android.gcm.GCMBroadcastReceiver@405282e0 that was originally registered here.
Are you missing a call to unregisterReceiver()?
Run Code Online (Sandbox Code Playgroud)
上述错误的原因是什么?怎么可以避免?
我收到以下错误:
"你是否错过了取消注册接收者的电话"
android.app.IntentReceiverLeaked:
Activity com.apps.activities.MainActivity has leaked IntentReceiver com.wwhere.fragment.MainRecyclerViewFragment$1@44d50ba8 that was originally registered here. Are you missing a call to unregisterReceiver()? at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:809)
at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:610)
at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1478)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1458)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1452)
at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:467)
Run Code Online (Sandbox Code Playgroud)
我的代码是:
private BroadcastReceiver actionConversation = new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent) {
setAdapter();
}
};
private void registerBroadCasts() {
IntentFilter intentConnection = new IntentFilter(Constants.CONVERSATION_SCREEN);
getActivity().registerReceiver(actionConversation, intentConnection);
}
Run Code Online (Sandbox Code Playgroud)
我呼吁registerBroadCasts()的onCreate方法.