Created
November 25, 2022 17:57
-
-
Save ikhlaqmalik13/cf8dcd148dcbcc9d5d7635fea3c4cd31 to your computer and use it in GitHub Desktop.
Vibrator
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
private lateinit var vibrator: Vibrator | |
vibrator = getSystemService(Context.VIBRATOR_SERVICE) as Vibrator | |
private fun vibrate() { | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |
vibrator.vibrate(VibrationEffect.createOneShot(500, VibrationEffect.DEFAULT_AMPLITUDE)); | |
} else { | |
vibrator.vibrate(500); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment