Can't catch Java (Android) Exception with try-catch , createBitmap

痞子三分冷 提交于 2019-12-04 21:58:39

I am pretty sure you are running out of memory for your device, which is why the 6th createBitmap is going to crash your application. Try the following:

try{
    Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);
} catch (Exception e) {
    e.printStackTrace();
} catch (OutOfMemoryError e) {
    e.printStackTrace();
}

This should properly give output for errors that are thrown. Let me know the output, you might need to manually call System.gc() to handle all the garbage collection youself.

Read this: Displaying Bitmaps Efficiently

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!