[英]How can I access the audio 'Priority Mode' on a device running Android 5.0?
Android 5.0 includes a new way to control which apps are allowed to make noise on your device: when you press the volume button, the popup now lets you to choose None (completely silent), Priority (only priority notifications make sound), or All (everything is allowed to make noise.) Android 5.0包含一种新方法来控制允许哪些应用在您的设备上发出噪音:当您按下音量按钮时,弹出窗口现在允许您选择无 (完全静音), 优先级 (仅优先通知发出声音)或全部 (一切都可以发出噪音。)
I would like my app to be able to query the device to find out which of these three modes is currently active, and also I would like to be able to change these modes (without requiring the device to be rooted). 我希望我的应用程序能够查询设备以找出当前活动的这三种模式中的哪一种,并且我希望能够更改这些模式(无需设备根植)。 Does anyone know how to do this?
有谁知道如何做到这一点?
So far, all I can find is a brief reference on this changelog : 到目前为止,我所能找到的只是对此更改日志的简要参考:
Setting the device to RINGER_MODE_SILENT causes the device to enter the new priority mode.
将设备设置为RINGER_MODE_SILENT会导致设备进入新的优先级模式。 The device leaves priority mode if you set it to RINGER_MODE_NORMAL or RINGER_MODE_VIBRATE.
如果将设置设置为RINGER_MODE_NORMAL或RINGER_MODE_VIBRATE,则设备将保留优先模式。
This works as described, which allows me a very limited ability to change "priority mode" by modifying the ringer mode in AudioManager . 这就像所描述的那样工作,它允许我通过修改AudioManager中的振铃模式来改变“优先模式”的能力非常有限。 That's not enough, though, as I need to be able to know exactly which of the three priority mode settings is currently active, and it would also be nice if I could change them more precisely than AudioManager allows.
但这还不够,因为我需要能够确切地知道当前活动的三种优先模式设置中的哪一种,如果我能比AudioManager允许的更精确地更改它们也会很好。
I've found a solution, but this requires root to change, because this setting is in Settings.Global. 我找到了一个解决方案,但这需要root来更改,因为此设置在Settings.Global中。
Name of setting is "zen_mode". 设置名称是“zen_mode”。
Values are: 价值观是:
ZENMODE_ALL = 0;
ZENMODE_PRIORITY = 1;
ZENMODE_NONE = 2;
EDIT: I've found another solution. 编辑:我找到了另一个解决方案。 Check NotificationListenerService.requestInterruptionFilter(int interruptionFilter).
检查NotificationListenerService.requestInterruptionFilter(int interruptionFilter)。 https://developer.android.com/reference/android/service/notification/NotificationListenerService.html Implementation example: https://github.com/kpbird/NotificationListenerService-Example
https://developer.android.com/reference/android/service/notification/NotificationListenerService.html实施示例: https : //github.com/kpbird/NotificationListenerService-Example
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.