AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

//通话音量

int max = am.getStreamMaxVolume( AudioManager.STREAM_VOICE_CALL );

int current = am.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 = am.getStreamMaxVolume( AudioManager.STREAM_ALARM );

current = sm.getStreamVolume( AudioManager.STREAM_ALARM );

Log.d(”ALARM”, “max : ” + max + ” current : ” + current);

设置音量的方法也很简单,AudioManager提供了方法:
public void setStreamVolume(int streamType, int index, int flags)
其中 streamType 有内置的常量,可以在AudioManager里面查到相关的定义

更多相关文章

  1. android HTTP post方法时,如何使用cookies
  2. Android将Uri转化为文件路径的方法
  3. A20启动LUNCH选项修改
  4. react-native调用Android原生模块
  5. Android-Intent的使用方法详解
  6. Android中RadioGroup RadioButton CheckBox多选按钮实现方法以及
  7. Android音量控制调节
  8. 浅谈Java中Collections.sort对List排序的两种方法
  9. Python list sort方法的具体使用

随机推荐

  1. Android项目总结之社会化分享
  2. android中adb不是内部或者外部指令以及丢
  3. 第2章 初识Android(安卓)App(第2讲)
  4. Android热修复之Sophix
  5. Android(安卓)程序反编译
  6. 自定义View-Rect和RectF
  7. Android使用ViewPager实现类似laucher左
  8. Android(安卓)layout之优化:使用include和
  9. tag tab label在android的区别
  10. Android(安卓)VideoView播放本地视频短暂