Android VibrationManager cancel is not stopping vibration
I have the following code that is supposed to start and stop vibration in my application:
fun Context.vibrate(wave: Boolean) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
(getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager).apply {
vibrate(
CombinedVibration.createParallel(makeEffect(wave)),
VibrationAttributes.Builder().setUsage(VibrationAttributes.USAGE_ALARM).build(),
)
}
} else {...