Android SDK 26是否可以设置通知通道的振动模式重复次数?



我正在尝试在本地通知上使用自定义振动。在阅读了一点之后,我在通知通道中设置了自定义振动模式,如下所示:

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)
}

但是它只振动一次并且只执行前四个索引。

例如,如果我的模式看起来像这样:

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)

它只针对第一行振动并停止。振动相当于:

val vibrationPattern = longArrayOf(0, 200, 500, 50)

我有一个想法,设置模式看起来像最后一个,并设置系统重复它几次,但我还没有找到如何做到这一点。

我很乐意在这里得到帮助。

use this:

notification.flags = Notification.FLAG_INSISTENT

放入NotificationManager.notify

最新更新