From 1bdfac3f727da6b4f2916ff21c24c098635fdcce Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 15 Sep 2024 08:04:47 +0200 Subject: [PATCH] Prevent NPE --- app/src/main/java/eu/faircode/email/FragmentRule.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentRule.java b/app/src/main/java/eu/faircode/email/FragmentRule.java index b7fc23a71b..a1c59b4151 100644 --- a/app/src/main/java/eu/faircode/email/FragmentRule.java +++ b/app/src/main/java/eu/faircode/email/FragmentRule.java @@ -1146,9 +1146,11 @@ public class FragmentRule extends FragmentBase { private void onSelectSound(Uri uri) { try { Log.i("Selected sound uri=" + uri); - getContext().getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); - if (!Helper.isPersisted(getContext(), uri, true, false)) - throw new IllegalStateException("No permission granted to access selected image " + uri); + if (uri != null) { + getContext().getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); + if (!Helper.isPersisted(getContext(), uri, true, false)) + throw new IllegalStateException("No permission granted to access selected image " + uri); + } } catch (Throwable ex) { Log.w(ex); }