if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
shouldPlayBeep = false;//检查当前是否是静音模式
}else{
shouldPlayBeep = true;
}
////////////////////////////
if (shouldPlayBeep && mediaPlayer != null) {
mediaPlayer.start();
try {
Thread.sleep(1300);
mediaPlayer.reset();
mediaPlayer.release();
} catch (InterruptedException e) {
e.printStackTrace();
}
// mediaPlayer.stop();
}else{
Vibrator vib = (Vibrator) context.getSystemService(Service.VIBRATOR_SERVICE);
vib.vibrate(milliseconds);
}
安卓响铃和震动