【问题标题】:Android notification small icon background is always blackAndroid通知小图标背景总是黑色
【发布时间】:2016-06-16 17:37:15
【问题描述】:

我使用 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);

【问题讨论】:

    标签: android android-5.0-lollipop android-notifications android-6.0-marshmallow android-statusbar


    【解决方案1】:

    解决了。

    使用.setColor(getResources().getColor(R.color.ColorPrime)) 代替.setColor(R.color.ColorPrime) 完全有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多