设置了Android系统卷 [英] Setting the Android System Volume
本文介绍了设置了Android系统卷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写它处理以下应用:
- 静音 - 使手机音量静音
- 低 - 使手机音量1点之上的沉默
- 中 - 让手机体积中
- 高级 - 让手机体积最大
手机体积包括铃声,视频,音频,游戏音量等。
Phone volume includes Ringer, video, audio , games volume etc.
我知道如何实现通过 AudioManager
静音模式。但对于2-4,我找不到任何有用的code片段。什么是我需要做什么?
I know how to achieve Silent mode through AudioManager
. But for 2-4 , I could not find any helpful code snippets. What do I need to do?
推荐答案
添加这在你的code 的onCreate()
方法,然后玩的0值以提高或降低音量其中0表示关
Add this in onCreate()
method of your code and then play around with the 0 value to increase or decrease the volume where 0 means OFF.
AudioManager mgr=null;
mgr=(AudioManager)getSystemService(Context.AUDIO_SERVICE);
mgr.setStreamVolume(AudioManager.STREAM_MUSIC, 0, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
mgr.setStreamVolume(AudioManager.STREAM_RING, 0, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
mgr.setStreamVolume(AudioManager.STREAM_ALARM, 0, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
mgr.setStreamVolume(AudioManager.STREAM_SYSTEM, 0, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
mgr.setStreamVolume(AudioManager.STREAM_NOTIFICATION, 0, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
这篇关于设置了Android系统卷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文