您好,登錄后才能下訂單哦!
首先先獲取AudioManager audio = (AudioManager) super
.getSystemService(Context.AUDIO_SERVICE);
正常模式
MyAudioManagerDemo.this.audio.setRingerMode(AudioManager.RINGER_MODE_NORMAL) ;
靜音模式
MyAudioManagerDemo.this.audio.setRingerMode(AudioManager.RINGER_MODE_SILENT) ;
震動模式
MyAudioManagerDemo.this.audio.setRingerMode(AudioManager.RINGER_MODE_VIBRATE) ;
減小音量
MyAudioManagerDemo.this.audio.adjustVolume(AudioManager.ADJUST_LOWER, 0) ;
增大音量
MyAudioManagerDemo.this.audio.adjustVolume(AudioManager.ADJUST_RAISE, 0) ;
private static final int SILENT = 0;
private static final int VIBRATE = 1;
private static final int NORMAL = 2;
int ringerMode = audio.getRingerMode();
switch (ringerMode) {
case SILENT:
Vibrator vibrator = (Vibrator) mContext
.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(400);
audio.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
break;
case VIBRATE:
audio.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
break;
case NORMAL:
audio.setRingerMode(AudioManager.RINGER_MODE_SILENT);
break;
default:
break;
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。