From 66675c0d1ad2a66d1a54afe1e3b1729186e863c3 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 24 Feb 2022 13:30:45 +0100 Subject: [PATCH] Added fail safe --- .../eu/faircode/email/EditTextMultiAutoComplete.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/EditTextMultiAutoComplete.java b/app/src/main/java/eu/faircode/email/EditTextMultiAutoComplete.java index 415505ece0..e2de487978 100644 --- a/app/src/main/java/eu/faircode/email/EditTextMultiAutoComplete.java +++ b/app/src/main/java/eu/faircode/email/EditTextMultiAutoComplete.java @@ -254,11 +254,13 @@ public class EditTextMultiAutoComplete extends AppCompatMultiAutoCompleteTextVie Drawable avatar = null; Uri lookupUri = ContactInfo.getLookupUri(parsed); - if (lookupUri != null) { - InputStream is = ContactsContract.Contacts.openContactPhotoInputStream( - context.getContentResolver(), lookupUri, false); - avatar = Drawable.createFromStream(is, email); - } + if (lookupUri != null) + try (InputStream is = ContactsContract.Contacts.openContactPhotoInputStream( + context.getContentResolver(), lookupUri, false)) { + avatar = Drawable.createFromStream(is, email); + } catch (Throwable ex) { + Log.e(ex); + } String e = parsed[0].getAddress(); String p = parsed[0].getPersonal();