How can I access Priority Mode audio on a device running Android 5.0?

Android 5.0 includes a new way to control which applications can interfere with your device: when you press the volume button, the pop-up window now allows you to select No (completely silent), Priority (only priority-based notifications sound) or All (all is allowed to make noise.)

New 'priority mode' controls in Android 5.0

I want my application to be able to request a device to find out which of these three modes is active, and also I would like to be able to change these modes (without requiring the device to be deployed). Does anyone know how to do this?

So far, I can find a short link in this change log :

Setting the device to RINGER_MODE_SILENT forces the device to switch to the new priority mode. The device exits priority mode if you set it to RINGER_MODE_NORMAL or RINGER_MODE_VIBRATE.

This works as described, which allows me to very restrict the ability to change the priority mode by changing the call mode

+6
source share
1 answer

I found a solution, but this requires changing root, because this parameter is in Settings.Global.

The parameter name is "zen_mode".

Values:

ZENMODE_ALL = 0; ZENMODE_PRIORITY = 1; ZENMODE_NONE = 2; 

EDIT: I found another solution. Check NotificationListenerService.requestInterruptionFilter (int interruptionFilter). https://developer.android.com/reference/android/service/notification/NotificationListenerService.html Implementation example: https://github.com/kpbird/NotificationListenerService-Example

+8
source

Source: https://habr.com/ru/post/977993/


All Articles