本文实例讲述了android编程获取和设置系统铃声和音量大小的方法。分享给大家供大家参考,具体如下:
通过程序获取android系统手机的铃声和音量。同样,设置铃声和音量的方法也很简单!
设置音量的方法也很简单,AudioManager提供了方法:
public voidsetStreamVolume(intstreamType,intindex,intflags)
其中streamType有内置的常量,去文档里面就可以看到。
JAVA代码:
AudioManager mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); //通话音量 int max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_VOICE_CALL ); int current = mAudioManager.getStreamVolume( AudioManager.STREAM_VOICE_CALL ); Log.d("VIOCE_CALL", "max : " + max + " current : " + current); //系统音量 max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_SYSTEM ); current = mAudioManager.getStreamVolume( AudioManager.STREAM_SYSTEM ); Log.d("SYSTEM", "max : " + max + " current : " + current); //铃声音量 max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_RING ); current = mAudioManager.getStreamVolume( AudioManager.STREAM_RING ); Log.d("RING", "max : " + max + " current : " + current); //音乐音量 max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_MUSIC ); current = mAudioManager.getStreamVolume( AudioManager.STREAM_MUSIC ); Log.d("MUSIC", "max : " + max + " current : " + current); //提示声音音量 max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_ALARM ); current = mAudioManager.getStreamVolume( AudioManager.STREAM_ALARM ); Log.d("ALARM", "max : " + max + " current : " + current);
本文章地址http://www.vzeo.com/news/xuetang/800668.html 由 友站网 编辑整理,转载请注明出处