Skip to content

Instantly share code, notes, and snippets.

@nieldeokar
Last active November 13, 2017 11:41
Show Gist options
  • Save nieldeokar/51ef75cbcb93e6c57046ff8fdc2f68e2 to your computer and use it in GitHub Desktop.
Save nieldeokar/51ef75cbcb93e6c57046ff8fdc2f68e2 to your computer and use it in GitHub Desktop.
It would create one shot vibration using VibrationEffect
@RequiresApi(api = Build.VERSION_CODES.O)
private void createOneShotVibrationUsingVibrationEffect() {
// 1000 : Vibrate for 1 sec
// VibrationEffect.DEFAULT_AMPLITUDE - would perform vibration at full strength
VibrationEffect effect = VibrationEffect.createOneShot(1000, VibrationEffect.DEFAULT_AMPLITUDE);
vibrator.vibrate(effect);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment