17 lines
535 B
Kotlin
17 lines
535 B
Kotlin
package com.adlerosn.brasilfurfest.helper
|
|
|
|
import android.content.Context
|
|
import android.os.Build
|
|
import android.os.VibrationEffect
|
|
import android.os.Vibrator
|
|
|
|
fun vibrate(context: Context, duration: Long) {
|
|
val v2 = context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator?
|
|
val v = v2!!
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
v.vibrate(VibrationEffect.createOneShot(duration, VibrationEffect.DEFAULT_AMPLITUDE))
|
|
} else {
|
|
@Suppress("DEPRECATION")
|
|
v.vibrate(duration)
|
|
}
|
|
} |