MeL*_*ine 4 android vibration notification-channel
我正在尝试在本地通知上使用自定义振动。阅读了一些内容后,我在通知通道中设置了自定义振动模式,如下所示:
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)
}
Run Code Online (Sandbox Code Playgroud)
但它只振动一次,并且只执行前四个索引。
例如,如果我的模式如下所示:
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)
Run Code Online (Sandbox Code Playgroud)
它仅在第一行振动并停止。振动等效于:
val vibrationPattern = longArrayOf(0, 200, 500, 50)
Run Code Online (Sandbox Code Playgroud)
我有一个想法,将模式设置为看起来像最后一个,并将系统设置为重复几次,但到目前为止我还没有找到如何做到这一点。
我很高兴在这里得到一些帮助。
小智 7
用这个 :
notification.flags = Notification.FLAG_INSISTENT
Run Code Online (Sandbox Code Playgroud)
在投入之前NotificationManager.notify
| 归档时间: |
|
| 查看次数: |
774 次 |
| 最近记录: |