Skip to content

Instantly share code, notes, and snippets.

@nieldeokar
Last active November 13, 2017 11:24
Show Gist options
  • Save nieldeokar/eea1dfa46ac7a54d5ee2dc0adc9eeee8 to your computer and use it in GitHub Desktop.
Save nieldeokar/eea1dfa46ac7a54d5ee2dc0adc9eeee8 to your computer and use it in GitHub Desktop.
This method would create a one shot vibration using VibrationEffects
@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