diff --git a/app/src/main/java/com/neo/speaktouch/di/module/ControllerModule.kt b/app/src/main/java/com/neo/speaktouch/di/module/ControllerModule.kt index 87c56121..f3dde72e 100644 --- a/app/src/main/java/com/neo/speaktouch/di/module/ControllerModule.kt +++ b/app/src/main/java/com/neo/speaktouch/di/module/ControllerModule.kt @@ -20,7 +20,9 @@ package com.neo.speaktouch.di.module import android.content.Context import android.media.AudioAttributes +import android.os.Build import android.os.Vibrator +import android.os.VibratorManager import android.speech.tts.TextToSpeech import com.neo.speaktouch.R import com.neo.speaktouch.controller.Controllers @@ -44,7 +46,14 @@ object ControllerModule { context: Context ) : VibratorController { - val vibrator = context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator + val vibrator = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + val vibratorManager = + context.getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager + vibratorManager.defaultVibrator + } else { + @Suppress("DEPRECATION") + context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator + } return VibratorController(vibrator) }