Search code examples
androidandroid-notificationsandroid-notification-bar

How to show different icons for status bar and notification bar in Android?


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 ?


Solution

  • 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.