Log.d(”ALARM”, “max : ” + max + ” current : ” + current);
设置音量的方法也很简单,AudioManager提供了方法:
[java] view plainpublic void setStreamVolume(int streamType, int index, int flags)
streamType为铃声类型,例如:AudioManager.STREAM_VOICE_CALL、AudioManager.STREAM_SYSTEM等,index为音量大小
falgs为标志位。
设置振动:
</pre><pre name="code" class="java"><span style="font-family:Arial, Helvetica, sans-serif;"><span style="white-space: normal;"><span style="font-family:monospace;"><span style="white-space: pre;"></span></span></span></span><pre name="code" class="java">mVibrator = (Vibrator) mContext.getSystemService(Service.VIBRATOR_SERVICE);
long[] pattern = {150, 100}; // OFF/ON/OFF/ON...
mVibrator.vibrate(pattern, -1);
静音:
设置系统声音为0就行
//通话时设置静音
System.out.println("isMicrophoneMute =" + audioManager.isMicrophoneMute());
audioManager.setMicrophoneMute(!audioManager.isMicrophoneMute());
//通话时设置免提
System.out.println("isSpeakerphoneOn =" + audioManager.isSpeakerphoneOn());
audioManager.setSpeakerphoneOn(!audioManager.isSpeakerphoneOn());
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
摘自:http://blog.csdn.net/qianhen136/article/details/7409775