简体   繁体   English

如何在运行Android 5.0的设备上访问音频“优先级模式”?

[英]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包含一种新方法来控制允许哪些应用在您的设备上发出噪音:当您按下音量按钮时,弹出窗口现在允许您选择 (完全静音), 优先级 (仅优先通知发出声音)或全部 (一切都可以发出噪音。)

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.

相关问题 如何拦截Android设备上的音频流? - How can I intercept the audio stream on an android device? 如何以编程方式检测 Android 设备是否处于暗模式? - How can I detect programmatically if the Android Device is in Dark Mode? 如何在工业安卓设备上访问开发者模式? - How to access developer mode on industrial android device? 我可以访问Android设备的音频输出以便在用户听到声音之前对其进行修改吗? - Can I access the audio output of an Android device in order to modify it before the user hears it? Android:如何访问音频文件? - Android: How can I get access to audio files? 如何将音频流传输到Android设备? - How Do I Stream Audio Into An Android Device? 如何将我的Android设备连接到OSX上运行的VM? - How can I connect my Android device to a VM running on OSX? 如何在基于Android的设备中访问音频以进行实时电话传输 - How can you access the audio for transmission in live phone calls in android based device 如何使用附加模式将音频录制到现有的音频文件中? - How can I record audio into existing audio file with append mode? 如何从Android 4.0以上的Android设备(如Whatsapp)获取音频文件? - How can I fetch the Audio files from Android Device above Android 4.0 like Whatsapp?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM