how to make phone vibrate android studio

Solutions on MaxInterview for how to make phone vibrate android studio by the best coders in the world

showing results for - "how to make phone vibrate android studio"
Linus
23 Apr 2017
1// Vibrate for 150 milliseconds
2private void shakeItBaby() {
3    if (Build.VERSION.SDK_INT >= 26) {
4        ((Vibrator) getSystemService(VIBRATOR_SERVICE)).vibrate(VibrationEffect.createOneShot(150, VibrationEffect.DEFAULT_AMPLITUDE));
5    } else {
6        ((Vibrator) getSystemService(VIBRATOR_SERVICE)).vibrate(150);
7    }
8}
9