Activity com.xxx.xxx.MainActivity has leaked IntentReceiver com.android.internal.policy.impl.PhoneWindow$2@422bc8b8 that was originally registered here. Are you missing a call to unregisterReceiver()?
当你在MainActivity 里面注册了广播,别忘了在页面销毁时进行取消注册,需要在onDesdroy()方法里调用unregisterReceiver()
@Override
protected void onDestroy() {
super.onDestroy();
if(broadcastReceiver!= null){
unregisterReceiver(broadcastReceiver);
}
}
本文详细解释了在Android开发中如何避免广播接收器泄漏的问题。重点在于在Activity的onDestroy()方法中正确地调用unregisterReceiver()来取消注册广播接收器,以防止内存泄漏。
492

被折叠的 条评论
为什么被折叠?



