val context = ApplicationProvider.getApplicationContext<Application>()
val vibratorManager = context?.getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager
val vibrator = vibratorManager.getDefaultVibrator()
if ((drawCount == 240) or (drawCount == 60)){
vibrator.vibrate(VibrationEffect.createOneShot(200, VibrationEffect.DEFAULT_AMPLITUDE))
} else if ((drawCount <= 60) and (drawCount.mod(5) == 0)){
vibrator.vibrate(VibrationEffect.createOneShot(100, VibrationEffect.DEFAULT_AMPLITUDE))
}
vibrator.cancel()
vibratorManager.cancel()
The code above causes a blank screen on the Emulator and on Samsung Galaxy Watch 4 - Wear OS 3.2 - Android 11.
I copied the code from several answers here. When I comment out the above code, my app runs great on the Emulator and on the said watch.
- Has anyone here written a code relating to the VibratorManager lately?
- Is it my Gradle?
- Should I use the latest Beta version of the Android Studio?
- Is there another way to accomplish my task which is NOT to notify the user but to vibrate the watch without requiring a user input?
Thanks