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里面查到相关的定义。

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/super005/archive/2010/07/02/5708669.aspx

更多相关文章

  1. Android获取StatusBa有效高度
  2. Android中 Bitmap和Drawable相互转换的方法
  3. android 获取IP
  4. Android(安卓)onSaveInstanceState和onRestoreInstanceState触发
  5. Android(安卓)监听音量加减
  6. Android(安卓)判断 app 是否安装的方法 (native.js)
  7. android EditText 只能输入无法删除的解决方法
  8. 浅谈Java中Collections.sort对List排序的两种方法
  9. Python list sort方法的具体使用

随机推荐

  1. Android(安卓)多线程-----AsyncTask详解
  2. android Setting中隐藏项实现原理与代码
  3. Android真的很火吗?
  4. Android自定义视图一:扩展现有的视图,添加
  5. Android将允许纯C/C++开发应用
  6. 最封闭的开源系统:话说 Android(安卓)的八
  7. 给小白分享几个学习Android的网站
  8. Android内核开发:图解Android系统的启动过
  9. Android下的单元测试
  10. Android中的MVP架构初探