gpt4 book ai didi

Android通知小图标背景一直是黑色

转载 作者:太空狗 更新时间:2023-10-29 16:00:11 25 4
gpt4 key购买 nike

我使用 NotificationBuilder 为 android 创建了通知,即使我设置了 .setColor(),它也会忽略颜色并将小图标的背景颜色设置为黑色。我的目标 SDK 是 23,最小 SDK 是 19。我用于调试的手机有 Android Marshmallow。感谢您的帮助。

.setContentTitle(msgTitle)
.setSmallIcon(R.mipmap.notification_icon)
.setColor(R.color.ColorPrime) // ColorPrime is red.
.setLargeIcon(msgIcon)
.setTicker(msgBody)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(msgBody).setBigContentTitle(msgTitle))
.setContentText(msgBody)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setPriority(Notification.PRIORITY_HIGH);

Preview

最佳答案

解决了。

而不是 .setColor(R.color.ColorPrime)使用 .setColor(getResources().getColor(R.color.ColorPrime))完全有效。

关于Android通知小图标背景一直是黑色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37865918/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com