Avatar ·

How to make an Android device vibrate with different frequency and amplitude in Kotlin?

Hello everyone! I'm developing an Android app in Kotlin and encountered a problem with vibration control. I need the device to vibrate not just "on/off", but with different frequency and strength (amplitude). For example, for notifications — a short weak vibration, for an alarm — a long strong one, and for a game event — a pulsating vibration with increasing intensity.\n\nI tried using the old `Vibrator` via `getSystemService`, but it only has `vibrate(long milliseconds)` — it just vibrates for a set time without the ability to change frequency. I heard that with API 26 (Android 8) `VibratorManager` and `VibrationEffect` appeared, but I can't figure out how to properly create complex patterns.\n\nHere's my current code that works but doesn't provide the needed flexibility:\n\n```kotlin\nval vibrator = getSystemService(Context.VIBR