获取android系统手机的铃声和音量
通过程序 获取android系统手机的铃声和音量。设置音量的方法也很简单,AudioManager提供了方法:
publicvoidsetStreamVolume(intstreamType,intIndex,intFlags)其中streamType有内置的常量,去文档里面就可以看到。
Java代码:
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
//通话音量
int max = audioManager.getStreamMaxVolume( AudioManager.STREAM_VOICE_CALL );
int current = audioManager.getStreamVolume( AudioManager.STREAM_VOICE_CALL );
//系统音量
max = audioManager.getStreamMaxVolume( AudioManager.STREAM_SYSTEM );
current = audioManager.getStreamVolume( AudioManager.STREAM_SYSTEM );
//铃声音量
max = audioManager.getStreamMaxVolume( AudioManager.STREAM_RING );
current = audioManager.getStreamVolume( AudioManager.STREAM_RING );
//音乐音量
max = audioManager.getStreamMaxVolume( AudioManager.STREAM_MUSIC );
current =audioManager.getStreamVolume( AudioManager.STREAM_MUSIC );
//提示声音音量
max = audioManager.getStreamMaxVolume( AudioManager.STREAM_ALARM );
current = audioManager.getStreamVolume( AudioManager.STREAM_ALARM );
................end!