【发布时间】:2013-10-08 14:39:36
【问题描述】:
在我的 onStop 和 onPause 方法中,我执行以下操作:
@Override
protected void onStop() {
if (backgroundBitmap != null) {
backgroundBitmap.recycle();
backgroundBitmap = null;
}
}
@Override
protected void onPause() {
imageService.setPauseWork(false);
imageService.setExitTasksEarly(true);
imageService.flushCache();
}
什么时候关闭屏幕 onPause 和 onStop 被调用,然后我得到这个异常:
java.lang.IllegalArgumentException: Cannot draw recycled bitmaps
看来他还在继续画,但位图已经被回收了?
当由于屏幕关闭而调用 onStop/onResume 时,我的想法不是回收我的位图并让图像工作者继续工作。这是个好主意还是有更好的方法?
【问题讨论】:
标签: android android-asynctask android-imageview android-lifecycle