user4351462
user4351462

Reputation: 181

Notification icon doesn't show in status bar in lollipop

Here's the code I'm using to show a notification.

notification = new Notification.Builder(context).setContentIntent(contentIntentTwo)
                        .setContentTitle("App name").setSmallIcon(R.drawable.ic_launcher).setLargeIcon(notificationLargeIconBitmap).getNotification();

The notification and notification icon show in the pull down notification drawer, but not in the status bar in lollipop.

Here's what it looks like in lollipop :

enter image description here

This happens only on lollipop.

Upvotes: 4

Views: 4162

Answers (2)

yfsx
yfsx

Reputation: 1986

for pre-lollipop version, you can still using drawable image. But for lollipop and later, you need transparent background image to be used for notification icon (png preferred). As i know that lollipop version or later will convert any non-transparent color into white color for notification icon for its simplicity and "complexion reduction" idea to reach material design.

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
            .setContentTitle(title)
            .setContentText(body)
            .setPriority(2)
            .setContentIntent(pendingIntent);
    mBuilder.setAutoCancel(true);
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
        mBuilder.setSmallIcon(R.mipmap.ic_launcher_transparant);
    }else{
        mBuilder.setSmallIcon(R.mipmap.ic_launcher);
    }

https://medium.com/swarm-nyc/complexion-reduction-a-new-trend-in-mobile-design-cef033a0b978#.fblfw0ohi

Upvotes: 0

tachyonflux
tachyonflux

Reputation: 20221

Lollipop changes all non-transparent pixels to white.

http://developer.android.com/about/versions/android-5.0-changes.html#BehaviorNotifications

Upvotes: 2

Related Questions