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 ?

james
  • 1,967
  • 3
  • 21
  • 27

2 Answers2

8

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.

erdemlal
  • 491
  • 5
  • 21
  • how to make the small icon **entirely white**? – Hammad Nasir Jan 29 '17 at 07:42
  • 2
    @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. – mhdjazmati Feb 25 '17 at 19:28
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.

Madhur Ahuja
  • 22,211
  • 14
  • 71
  • 124
  • 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? – james Jul 15 '14 at 10:32
  • No. If you meant icon no.5 in the link. It will be same – Madhur Ahuja Jul 15 '14 at 10:43
  • 1
    so there is no way to use different icon for that ? Only small icon will show on both at status bar and notification bar ? – james Jul 15 '14 at 10:47
  • 1
    Oh i forgot that, that could be the solution. Thanks you. – james Jul 15 '14 at 10:54
  • And please edit your answer for "custom notification layout" so i can accept that. – james Jul 15 '14 at 10:58