I have an app that needs to be able to override Do Not Disturb access in Android 7/8. I have code that checks for the permission and opens the Do Not Disturb Access screen if it's not detected:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
&& !notificationManager.isNotificationPolicyAccessGranted()) {
Intent intent = new Intent(
android.provider.Settings
.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS);
context.startActivity(intent);
As well, I have this permission set up in the manifest:
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
This works fine on some devices and in all the virtual devices I've used it on, but on other devices, like a Pixel running Android 8, my app simply does not appear in the Do Not Disturb Access list and therefore the user cannot grant it the ability to override Do Not Disturb. Is there a specific permission or something Android is looking for to have an App appear in the Do Not Disturb Access list consistently?