Skip to content

Instantly share code, notes, and snippets.

@yasukotelin
Created October 28, 2020 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yasukotelin/7283c34206ef3a42c58b4b843fa8ab4e to your computer and use it in GitHub Desktop.
Save yasukotelin/7283c34206ef3a42c58b4b843fa8ab4e to your computer and use it in GitHub Desktop.
fun Fragment.performHapticFeedback(effectId: Int) {
val vibrator = requireContext().getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
vibrator.vibrate(VibrationEffect.createPredefined(effectId))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment