Issue
in my onStop and onPause methods i do the following:
@Override
protected void onStop() {
if (backgroundBitmap != null) {
backgroundBitmap.recycle();
backgroundBitmap = null;
}
}
@Override
protected void onPause() {
imageService.setPauseWork(false);
imageService.setExitTasksEarly(true);
imageService.flushCache();
}
when is switch the screen off onPause and onStop gets called and afterwards i get this exception:
java.lang.IllegalArgumentException: Cannot draw recycled bitmaps
So it seems that he continues drawing but the bitmap is allready recycled ?
My idea is not to recylce my bitmap and let the imageworker continue doing his work, when onStop/onResume is called due to screen off. Is this a good idea or is there a better approach ?
Solution
ok i got it i use now
pm =(PowerManager) getSystemService(Context.POWER_SERVICE);
if (pm.isScreenOn() == false) { ... }
to check why onResume and onStop are getting called
Answered By - AdrianoCelentano
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.