Sarthak Mishra
Sarthak Mishra

Reputation: 1114

Seperate Notification icon for status bar and main notiffication

Well i know how build a notification , my problem is to have different icon in the status bar and background for the icon when you expand . Please see the image it is self explanatory . Thank you for helping enter image description here

How to get the blue background for the small icon when expanded ? Thank you !!!

Upvotes: 3

Views: 388

Answers (2)

saeed
saeed

Reputation: 1955

You can set color Using

.setColor(getResources().getColor(R.color.yourcolor))

And The complete code Looks like

Notification.Builder nb = new Notification.Builder(context)
    .setContentTitle("title")
    .setContentText("content")
    .setAutoCancel(true)
    .setColor(getResources().getColor(R.color.primary))
    .setLargeIcon(largeIcon)
    .setSmallIcon(small_icon)
    .setTicker(s.getText());
    NotificationManager nm = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
    nm.notify(100, nb.build());

Hope this helps you

Upvotes: 0

Raghav Satyadev
Raghav Satyadev

Reputation: 738

use this code for building notifications.

Notification.Builder nb = new Notification.Builder(context)
    .setContentTitle("title")
    .setContentText("content")
    .setAutoCancel(true)
    .setColor(ContextCompat.getColor(context, R.color.ANYCOLOR))
    .setLargeIcon(largeIcon)
    .setSmallIcon(small_icon)
    .setTicker(s.getText());
    NotificationManager nm = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
    nm.notify(100, nb.build());

in this code you have to replace small and large icons.

Upvotes: 1

Related Questions