I am trying to use a custom vibration on local notifications. After reading a bit I set the custom vibration pattern in the Notification Channel, like this:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val notificationChannel =
NotificationChannel(NotificationChannels.CHANNEL_ID, channelName, importance)
...
notificationChannel.enableVibration(true)
notificationChannel.vibrationPattern = vibrationPattern
notificationManager.createNotificationChannel(notificationChannel)
}
But it vibrates only once and executes only the first four indexes.
For example, if my pattern looks like this:
val vibrationPattern = longArrayOf(
0, 200, 500, 50,
0, 200, 500, 50,
0, 200, 500, 50,
0, 200, 500, 50,
0, 200, 500, 50,
0, 200, 500, 50)
It vibrates only regarding the first row and stops. The vibrations are equivalent to this:
val vibrationPattern = longArrayOf(0, 200, 500, 50)
I had an idea to set the pattern to look like the last one and to set the system to repeat it several times, but I did not find how to do it so far.
I will be glad to get some help here.