在 Android 中设置通知时,从 Oreo 开始,您还需要设置 NotificationChannel
为了设置它,您需要给它一个 name: String
和 description: String
这是可选的。
val name = "test channel"
val description = "test description"
val importance = NotificationManager.IMPORTANCE_DEFAULT
val channel = NotificationChannel("ID", name, importance)
channel.description = description
根据文档,我无法弄清楚为什么需要输入这两个值,它们不会出现在 UI 中,甚至在新的 Android P 测试版中也不会。
创建 NotificationChannel 时使用的名称和描述是什么?
编辑:
正如前两个答案所证明的那样,我在询问时可能不清楚。我知道
NotificationChannel
是为了,我不清楚名称和描述属性是为了什么。
最佳答案
purpose of NotificationChannel
NotificationChannel
使我们的应用程序开发人员能够将我们的通知分组到组 channel 中,用户能够一次修改整个 channel 的通知设置功能用户可以从应用程序设置中执行以下操作:
purpose of NotificationChannel name
NotificationChannel 名称用于在系统设置中显示 NotificationChannel
setName()
用于设置 NotificationChannel 的名称setName()
设置 NotificationChannel 的用户可见名称。建议的最大长度为 40 个字符;如果值太长,可能会被截断。
purpose of NotificationChannel description
NotificationChannel Description
设置
NotificationChannel
的用户可见描述.指定用户在系统设置中看到的描述
关于android - NotificationChannel 名称和描述的用途,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51685489/