Created
October 28, 2020 15:39
-
-
Save yasukotelin/7283c34206ef3a42c58b4b843fa8ab4e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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