Intercept ActivityNotFoundException for ACTION_MANAGE_OVERLAY_PERMISSION

This commit is contained in:
Alexander-- 2020-03-12 05:32:20 +06:59
parent 1cc5a67d82
commit 9cb3cf250c

View file

@ -2,6 +2,7 @@ package org.schabi.newpipe.util;
import android.Manifest; import android.Manifest;
import android.app.Activity; import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@ -89,7 +90,10 @@ public class PermissionHelper {
if (!Settings.canDrawOverlays(context)) { if (!Settings.canDrawOverlays(context)) {
Intent i = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + context.getPackageName())); Intent i = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + context.getPackageName()));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
context.startActivity(i); context.startActivity(i);
} catch (ActivityNotFoundException ignored) {
}
return false; return false;
} else return true; } else return true;
} }