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); //系統(tǒng)音量
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);
設(shè)置音量 AudioManager提供了方法: public void setStreamVolume(int streamType, int index, int flags) streamType為鈴聲類型,,例如:AudioManager.STREAM_VOICE_CALL、AudioManager.STREAM_SYSTEM等,,index為音量大小 falgs為標(biāo)志位,。
|