在我的 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 因屏幕关闭而被调用时。这是一个好主意还是有更好的方法?