Android trying to use a recycled bitmap, not in my code

前端 未结 6 1368
滥情空心
滥情空心 2020-12-30 00:56

I get this stacktrace from the Market developer console every once in a while; I can\'t find any way to repro the error. It\'s happening while displaying a splashscreen Imag

6条回答
  •  轮回少年
    2020-12-30 00:57

    This exception occurs when you try to recycle or use a recycled bitmap. You should not remove bitmap.recycle() function from your existing code, it may cause Out Of Memory Error. You can try this below code to fix the issue.

    BitmapDrawable bitmapDrawable = ((BitmapDrawable) profileWallpaper.getDrawable());
    
                    if (null != bitmapDrawable && !bitmapDrawable.getBitmap().isRecycled()) {
    
                        bitmapDrawable.getBitmap().recycle();
                    } else {
    
                        log("bitmap is already recycled");
                    }
    
                    bitmapDrawable = null;
    

    Note: profileWallpaper is your imageView object

提交回复
热议问题