Prevent NPE

master
M66B 2 weeks ago
parent 117cb38511
commit 1bdfac3f72

@ -1146,9 +1146,11 @@ public class FragmentRule extends FragmentBase {
private void onSelectSound(Uri uri) { private void onSelectSound(Uri uri) {
try { try {
Log.i("Selected sound uri=" + uri); Log.i("Selected sound uri=" + uri);
getContext().getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); if (uri != null) {
if (!Helper.isPersisted(getContext(), uri, true, false)) getContext().getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
throw new IllegalStateException("No permission granted to access selected image " + uri); if (!Helper.isPersisted(getContext(), uri, true, false))
throw new IllegalStateException("No permission granted to access selected image " + uri);
}
} catch (Throwable ex) { } catch (Throwable ex) {
Log.w(ex); Log.w(ex);
} }

Loading…
Cancel
Save