BroadcastReceiver在Activity中注册则要在其中注销
否则会报错
09-06 19:20:25.281 4952-4952/com.segway.robot.client E/ActivityThread: Activity com.segway.robot.client.update.view.UpdateInfoDialogActivity has leaked IntentReceiver com.segway.robot.client.update.model.UpdateDownloadReceiver@381311b that was originally registered here. Are you missing a call to unregisterReceiver()?
但是往往一些后台任务是不想在activity中进行注销的,这个时候可以使用application的context进行注册。
本文讲解了BroadcastReceiver在Activity中的注册及注销流程,避免内存泄漏。同时介绍了在不希望Activity中注销的情况下,如何使用Application的Context进行注册。
380

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



