本文介绍了在静音的Android在全球的声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可用于从应用程序按钮静音全局声音的方法?
Is there a method that can be used to mute the global sound from an application button?
推荐答案
他们把它复杂得多,它必须是。你可以使用<$c$c>AudioManager.setStreamMute()$c$c>.随意使用下面的code。
They make it more complicated than it has to be. You can just use AudioManager.setStreamMute()
. Feel free to use the code below.
//mute audio
AudioManager amanager=(AudioManager)getSystemService(Context.AUDIO_SERVICE);
amanager.setStreamMute(AudioManager.STREAM_NOTIFICATION, true);
amanager.setStreamMute(AudioManager.STREAM_ALARM, true);
amanager.setStreamMute(AudioManager.STREAM_MUSIC, true);
amanager.setStreamMute(AudioManager.STREAM_RING, true);
amanager.setStreamMute(AudioManager.STREAM_SYSTEM, true);
//unmute audio
AudioManager amanager=(AudioManager)getSystemService(Context.AUDIO_SERVICE);
amanager.setStreamMute(AudioManager.STREAM_NOTIFICATION, false);
amanager.setStreamMute(AudioManager.STREAM_ALARM, false);
amanager.setStreamMute(AudioManager.STREAM_MUSIC, false);
amanager.setStreamMute(AudioManager.STREAM_RING, false);
amanager.setStreamMute(AudioManager.STREAM_SYSTEM, false);
这篇关于在静音的Android在全球的声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!