安卓响铃和震动

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);
}

安卓响铃和震动

上一篇:Mac Android8.0源码编译笔记


下一篇:React Native之配置URL Scheme(iOS Android)