From 9cb3cf250c6db2bded79ad04dbbe4268b8e5e351 Mon Sep 17 00:00:00 2001 From: Alexander-- Date: Thu, 12 Mar 2020 05:32:20 +0659 Subject: [PATCH] Intercept ActivityNotFoundException for ACTION_MANAGE_OVERLAY_PERMISSION --- .../main/java/org/schabi/newpipe/util/PermissionHelper.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/util/PermissionHelper.java b/app/src/main/java/org/schabi/newpipe/util/PermissionHelper.java index f32bb6587..19dab6ef7 100644 --- a/app/src/main/java/org/schabi/newpipe/util/PermissionHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/PermissionHelper.java @@ -2,6 +2,7 @@ package org.schabi.newpipe.util; import android.Manifest; import android.app.Activity; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; @@ -89,7 +90,10 @@ public class PermissionHelper { if (!Settings.canDrawOverlays(context)) { Intent i = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + context.getPackageName())); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - context.startActivity(i); + try { + context.startActivity(i); + } catch (ActivityNotFoundException ignored) { + } return false; } else return true; }