如何在运行Android 5.0的设备上访问音频“优先级模式”?
我希望我的应用程序能够查询设备以找出当前活动的这三种模式中的哪一种,并且我希望能够更改这些模式(无需设备根植).有谁知道如何做到这一点?
到目前为止,我所能找到的只是一个简短的参考on this changelog:
Setting the device to RINGER_MODE_SILENT causes the device to enter the new priority mode. The device leaves priority mode if you set it to RINGER_MODE_NORMAL or RINGER_MODE_VIBRATE.
这就像所描述的那样工作,它允许我通过修改ringer mode in AudioManager来改变“优先模式”的能力非常有限.但这还不够,因为我需要能够确切地知道当前活动的三种优先模式设置中的哪一种,以及如果我能比AudioManager允许更精确地更改它们也会很好.
解决方法
设置名称是“zen_mode”.
价值观是:
ZENMODE_ALL = 0; ZENMODE_PRIORITY = 1; ZENMODE_NONE = 2;
编辑:我找到了另一个解决方案.检查NotificationListenerService.requestInterruptionFilter(int interruptionFilter). https://developer.android.com/reference/android/service/notification/NotificationListenerService.html
实施例:https://github.com/kpbird/NotificationListenerService-Example
以上是来客网为你收集整理的如何在运行Android 5.0的设备上访问音频“优先级模式”?全部内容,希望文章能够帮你解决如何在运行Android 5.0的设备上访问音频“优先级模式”?所遇到的程序开发问题。
如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。