From 88336e16f4b5f18f551480b893253a7fc44fb341 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 28 Sep 2021 18:21:32 +0200 Subject: [PATCH] Small improvement --- app/src/main/java/eu/faircode/email/Shortcuts.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Shortcuts.java b/app/src/main/java/eu/faircode/email/Shortcuts.java index a95a4c22c9..0157f367fa 100644 --- a/app/src/main/java/eu/faircode/email/Shortcuts.java +++ b/app/src/main/java/eu/faircode/email/Shortcuts.java @@ -47,6 +47,7 @@ import androidx.core.graphics.drawable.IconCompat; import androidx.lifecycle.LifecycleOwner; import androidx.preference.PreferenceManager; +import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; @@ -228,9 +229,13 @@ class Shortcuts { if (avatar != null && Helper.hasPermission(context, Manifest.permission.READ_CONTACTS)) { // Create icon from bitmap because launcher might not have contacts permission - InputStream is = ContactsContract.Contacts.openContactPhotoInputStream( - context.getContentResolver(), avatar); - bitmap = BitmapFactory.decodeStream(is); + ContentResolver resolver = context.getContentResolver(); + try (InputStream is = ContactsContract.Contacts + .openContactPhotoInputStream(resolver, avatar)) { + bitmap = BitmapFactory.decodeStream(is); + } catch (IOException ex) { + Log.e(ex); + } } boolean identicon = false;