【问题标题】:How can I create badge number in icon launcher kotlin如何在图标启动器 kotlin 中创建徽章编号
【发布时间】:2021-12-21 19:26:11
【问题描述】:

我的故事是像这样在图标或徽章编号顶部制作数字 home screen icon 但它不适用于所有设备,为什么? 以及如何解决?

【问题讨论】:

标签: android kotlin numbers badge


【解决方案1】:

如果通知通知android系统为您的应用程序图标添加徽章, 您可以使用以下代码显示通知

val id = "my_channel_01"
val name = getString(R.string.channel_name)
val descriptionText = getString(R.string.channel_description)
val importance = NotificationManager.IMPORTANCE_LOW
val mChannel = NotificationChannel(id, name, importance).apply {
    description = descriptionText
    setShowBadge(true)
}
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.createNotificationChannel(mChannel)

【讨论】:

    猜你喜欢
    • 2018-04-25
    • 1970-01-01
    • 2011-05-21
    • 1970-01-01
    • 2017-02-13
    • 1970-01-01
    • 1970-01-01
    • 2022-11-10
    • 1970-01-01
    相关资源
    最近更新 更多