android vibrate device

Solutions on MaxInterview for android vibrate device by the best coders in the world

showing results for - "android vibrate device"
Samantha
20 Sep 2020
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}