両方対応する場合ってこう書くのか、、勉強になるなぁ、、
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
vibrator.vibrate(VibrationEffect.createOneShot(500, VibrationEffect.DEFAULT_AMPLITUDE)) // New vibrate method for API Level 26 or higher
} else {
vibrator.vibrate(500) // Vibrate method for below API Level 26
}
android - how to vibrate device on button click using vibrator effects? Using Kotlin - Stack Overflow https://stackoverflow.com/questions/47880450/how-to-vibrate-device-on-button-click-using-vibrator-effects-using-kotlin?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa