From 8f057a0c95d674976291ea50627ce268e53c0b50 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 18 Aug 2018 18:13:51 +0200 Subject: [PATCH] try to catch out of memory exception --- .../eu/siacs/conversations/persistance/FileBackend.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java index ee3d40dff..adcabc47f 100644 --- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java @@ -784,11 +784,12 @@ public class FileBackend { bitmap = BitmapFactory.decodeStream(mXmppConnectionService.getContentResolver().openInputStream(uri)); return getPepAvatar(bitmap, Bitmap.CompressFormat.PNG, 100); } catch (Exception e) { + return null; + } finally { if (bitmap != null) { bitmap.recycle(); } } - return null; } private Avatar getPepAvatar(Bitmap bitmap, Bitmap.CompressFormat format, int quality) { @@ -822,6 +823,9 @@ public class FileBackend { avatar.width = bitmap.getWidth(); avatar.height = bitmap.getHeight(); return avatar; + } catch (OutOfMemoryError e) { + Log.d(Config.LOGTAG,"unable to convert avatar to base64 due to low memory"); + return null; } catch (Exception e) { return null; }