你缺少unregisterReceiver()的调用?在android系统 [英] Are you missing a call to unregisterReceiver() ? in android
本文介绍了你缺少unregisterReceiver()的调用?在android系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到以下错误
你缺少一个电话注销接收
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)
我的code是
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);
}
和我打电话的 registerBroadCasts()在onCreate方法。
And i call registerBroadCasts() in onCreate method.
推荐答案
我猜你正在使用 GCM
在application.In你在哪里注册的设备到活动 GCM
,写上如下code:
I guess you are using GCM
in your application.In the activity where you are registering a device to GCM
,write the following code:
@Override
public void onDestroy() {
// TODO Auto-generated method stub
try{
if(mHandleMessageReceiver!=null)
unregisterReceiver(mHandleMessageReceiver);
}catch(Exception e)
{
}
super.onDestroy();
}
其中 mHandleMessageReceiver 是实例的广播接收器
这篇关于你缺少unregisterReceiver()的调用?在android系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文