I am using Android's VIBRATOR_SERVICE
to give a haptic feedback for a button touch.
((Vibrator) getSystemService(VIBRATOR_SERVICE)).vibrate(300);
Android Studio give me warning that method vibrate(interval)
is deprecated I should use VibrationEffect
for API>23.
So I usedVibrationEffect
's method createOneShot
which takes 2 params: interval, and amplitude.
I tried searching for it but got no clue about what to pass as amplitude
, anybody got any idea about how to use it?
Update Added code
// Vibrate for 150 milliseconds
private void shakeItBaby() {
if (Build.VERSION.SDK_INT >= 26) {
((Vibrator) getSystemService(VIBRATOR_SERVICE)).vibrate(VibrationEffect.createOneShot(150,10));
} else {
((Vibrator) getSystemService(VIBRATOR_SERVICE)).vibrate(150);
}
}