android - Kotlin:将 LongArray 定义为 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())
如果你真的想要。
推荐阅读
- module - 将源文件划分为多个模块的常规方法是什么?
- java - 如何检查字符串的两个索引以查看字符是否匹配
- python - Keras 上的 model.compile 和 model.fit_generator 出错
- javascript - 使用 MUI 按钮时:TypeError:无法读取未定义的属性“borderRadius”
- java - RecyclerView onBindViewHolder 没有绘制我的视图
- http - gRPC, over HTTP/2 是什么意思?
- sccm - 为什么 LAN 唤醒计划部署无法正常工作 SCCM 1802?
- kendo-ui - Kendo UI createlink和insertimage弹出模式不显示输入框
- python - 正则表达式在python中的特定字符串之间提取特定数据
- c - C中的Socket程序,发送消息阻止进一步的代码