码迷,mamicode.com
首页 > 移动开发 > 详细

设置和获取Android中各种音量

时间:2014-04-30 02:26:46      阅读:586      评论:0      收藏:0      [点我收藏+]

标签:android   log   c   ext   t   get   sp   int   set   type   text   

通过程序获取android系统手机的铃声和音量。同样,设置铃声和音量的方法也很简单!

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

设置和获取Android中各种音量,码迷,mamicode.com

设置和获取Android中各种音量

标签:android   log   c   ext   t   get   sp   int   set   type   text   

原文地址:http://www.cnblogs.com/profession/p/3695907.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!