12

I'm creating android notification according to android documentation. I used large icon and small icon for Notification bar.

In this case small icon is showing on both status bar and notification bar . I want to show different icons for status bar and notification bar, how i can achieve that ?

2 Answers 2

9

In the documentation; there are notification area and notification drawer, i think in your case status bar means the notification area. You can use the following code to create a notification by setting both small icon and large icon.

Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.ic_icon); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.logo).setLargeIcon(bm).setContentTitle("title").setContentText("body"); 

Large icon is a bitmap and it is shown in notification drawer, small icon is shown in notification area but also in the notification drawer, in the bottom right corner of the large icon. It must be entirely white. If the small icon is colorful, it is shown as a white square in the notification area.

Sign up to request clarification or add additional context in comments.

2 Comments

how to make the small icon entirely white?
@HammadNasir simply in your android studio click new image assets then choose icon for notification and status bar then choose your image and android studio will create the right icons.
1

There are different API's for each. See below:

Notification.Builder nb = new Notification.Builder(context) .setContentTitle("title") .setContentText("content") .setAutoCancel(true) .setLargeIcon(largeIcon) .setSmallIcon(R.drawable.small_icon) .setTicker(s.getText()); 

http://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#setSmallIcon%28int%29

http://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#setLargeIcon%28android.graphics.Bitmap%29

OR

As an alternative, you could use a custom notification layout.

5 Comments

Yes, i created notification as the same you described. But this method ".setSmallIcon(R.drawable.small_icon)" is show small icon at Notification bar AND at status bar. Is that right ? If yes, i want to use iconA.png for Status bar icon and iconB.png for small icon at Notification bar, how can i do that?
No. If you meant icon no.5 in the link. It will be same
so there is no way to use different icon for that ? Only small icon will show on both at status bar and notification bar ?
Oh i forgot that, that could be the solution. Thanks you.
And please edit your answer for "custom notification layout" so i can accept that.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.