how to vibrate android java

Solutions on MaxInterview for how to vibrate android java by the best coders in the world

showing results for - "how to vibrate android java"
Kendrick
19 May 2019
1import android.os.Vibrator;
2...
3Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
4// Vibrate for 500 milliseconds
5if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
6    v.vibrate(VibrationEffect.createOneShot(500, VibrationEffect.DEFAULT_AMPLITUDE));
7} else {
8    //deprecated in API 26 
9    v.vibrate(500);
10}
11