您好,登录后才能下订单哦!
首先先获取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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。