I am testing my App for action overlay on devices like (Coolpad(Lolipop MRI), Samsung Galaxy grand neo(Kitkat), Redmi(Marshmallow), Lenovo z2 plus(Marshmallow)) to show a dialog over incoming call screen. things seems to work for devices other than lenovo z2 plus().
formally asking the permission directly I was getting exception:
public void testPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!Settings.canDrawOverlays(this)) {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + getPackageName()));
startActivityForResult(intent, ACTION_MANAGE_OVERLAY_PERMISSION_REQUEST_CODE);
}
}
}
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.settings.action.MANAGE_OVERLAY_PERMISSION
Now I changed asking permission to :
public void testPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!Settings.canDrawOverlays(this)) {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + getPackageName()));
if (intent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(intent, ACTION_MANAGE_OVERLAY_PERMISSION_REQUEST_CODE);
}
}
}
}
but it is still not able to ask for the permission in zuk 2. immediate help is appreciated.