I am trying to programmatically find out for which apps the Do Not Disturb setting is bypassed exceptionally.
So far, I am using the following code to check whether the phone is set in Do not Disturb mode or not :
public static boolean isDnDModeEnabled(Context context)
{
if(Build.VERSION.SDK_INT <23)
return false;
try {
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
int filterValue = notificationManager.getCurrentInterruptionFilter();
switch(filterValue)
{
case NotificationManager.INTERRUPTION_FILTER_ALL : Log.d("DND","Interruption filter all");
break;
case NotificationManager.INTERRUPTION_FILTER_ALARMS : Log.d("DND","Interruption filter alarms");
break;
case NotificationManager.INTERRUPTION_FILTER_PRIORITY : Log.d("DND","Interruption filter priority");
break;
case NotificationManager.INTERRUPTION_FILTER_UNKNOWN : Log.d("DND","Interruption filter unknown");
break;
case NotificationManager.INTERRUPTION_FILTER_NONE : Log.d("DND","Interruption filter none");
break;
}
if(filterValue == NotificationManager.INTERRUPTION_FILTER_ALL)
return false;
else if(filterValue == NotificationManager.INTERRUPTION_FILTER_PRIORITY)
{
//Logic based on which apps are allowed as priority
return true; //or false
}
else
return true;
}
catch(Exception e)
{
return false;
}
}
When I click on the Priority app notiications tab, I get a list of all installed apps for which I get to choose which apps to allow as priority exceptions.
My question is how to programmatically get the list of apps which are allowed as priority exceptions for Do Not Disturb mode, and thereby define the logic replacing the comment in the above code? Any solutions would be thoroughly appreciated.