Android: Detect Do Not Disturb status?

Paul Ruiz picture Paul Ruiz · Jul 13, 2015 · Viewed 12.3k times · Source

I was just wondering if there's a way to check if an Android device (21+) is in Do Not Disturb mode? I know there's AudioManager.RINGER_MODE_SILENT, but I was wondering if that pertains to this situation, or if there's a better way to check?

Answer

ssice picture ssice · Jul 26, 2016

With pointers from Android how to turn on do not disturb (dnd) programmatically:

In SDK 23, android.app.NotificationManager provides the interface you need, namely NotificationManager.getCurrentInterruptionFilter().

It should return one of:

  • INTERRUPTION_FILTER_PRIORITY
  • INTERRUPTION_FILTER_ALARMS
  • INTERRUPTION_FILTER_NONE
  • INTERRUPTION_FILTER_ALL
  • INTERRUPTION_FILTER_UNKNOWN

According to Google Help on Nexus Devices Do not Disturb is a feature of Android >= 6.0, so SDK 23 should be reasonable to ask. If it is not, I think it would be reasonable to ask why, to be able to provide a workaround.