Search code examples
androidandroid-5.0-lollipopandroid-notificationsandroid-6.0-marshmallowandroid-statusbar

Android notification small icon background is always black


I created notification for android with NotificationBuilder, eventhough i set .setColor(), it ignores the color and sets small icon's background color black. My target SDK is 23 and min SDK is 19. And the phone that i am using for debug has Android Marshmallow.Thanks for help.

.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


Solution

  • Solved it.

    Instead of .setColor(R.color.ColorPrime) using .setColor(getResources().getColor(R.color.ColorPrime)) totally worked.