I'm getting following exception:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.settings.action.MANAGE_OVERLAY_PERMISSION dat=package:com.my.app }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1816)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1525)
at android.app.Activity.startActivityForResult(Activity.java:4265)
This happened in an app that's already a few years old and is working flawlessly. Now I got this exception for an android 7 device, model ZUK Z1. Any ideas? Seems like a problem with the rom. Does this rom offer an alternative way to get overlay drawing permissions?
Edit - here's the function I use to get permissions
public static void checkOverlayPermission(Activity activity)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(activity))
{
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + activity.getPackageName()));
activity.startActivityForResult(intent, BaseDef.OVERLAY_PERMISSION_REQ_CODE);
}
}
Try this one.This is working for me. It may help you
if (!Settings.canDrawOverlays(this)) {
Intent localIntent = new Intent("android.settings.action.MANAGE_OVERLAY_PERMISSION");
localIntent.setData(Uri.parse("package:" + getPackageName()));
localIntent.setFlags(268435456);
startActivity(localIntent);
}
Try this if your rom is the issue
Basically you can't just check all rom which have issues with settings. The code above works fine in android N as well. I tested this myself.
What you can do is put your code inside a try catch block and when you enters the catch block show user a dialog which asks him to give overlay permission manually instead taking him directly to the settings page.
There are some roms basically the custom roms which have issues with some system settings so this is the best approach you can use to tackle these situations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With