Kotlin:将 LongArray 定义为 Notification.Builder.setVibrate(LONG_ARRAY)
Kotlin: define LongArray to Notification.Builder.setVibrate(LONG_ARRAY)
我正在使用 Kotlin 并想为通知设置振动。
.setVibrate()
函数需要 LongArray
但我无法为其定义。
var Builder = NotificationCompat.Builder(this,R.string.channel_name.toString())
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("my notification Title")
.setContentText("somthing else for content")
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setAutoCancel(true)
.setVibrate(LONG_ARRAY)
我在网上搜索,但只找到 java 的解决方案。感谢您的帮助。
.setVibrate(longArrayOf(1L, 2L, 3L))
会工作得很好,或者
.setVibrate(listOf(1L, 2L, 3L).toLongArray())
如果你真的想要的话。
我正在使用 Kotlin 并想为通知设置振动。
.setVibrate()
函数需要 LongArray
但我无法为其定义。
var Builder = NotificationCompat.Builder(this,R.string.channel_name.toString())
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("my notification Title")
.setContentText("somthing else for content")
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setAutoCancel(true)
.setVibrate(LONG_ARRAY)
我在网上搜索,但只找到 java 的解决方案。感谢您的帮助。
.setVibrate(longArrayOf(1L, 2L, 3L))
会工作得很好,或者
.setVibrate(listOf(1L, 2L, 3L).toLongArray())
如果你真的想要的话。