安卓响铃和震动

【安卓响铃和震动】志不强者智不达,言不信者行不果。这篇文章主要讲述安卓响铃和震动相关的知识,希望能为你提供帮助。

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





















    推荐阅读