Ahmad
Ahmad

Reputation: 72653

Android - Change Notification Icon

I would like to know if its possible to have an different Notificationbar Icon than the Launcher or Application Icon. I would like to display an other icon for my push notifications. Is this possible? Thanks.

Upvotes: 2

Views: 8422

Answers (2)

Avinash
Avinash

Reputation: 264

 Notification n  = new Notification.Builder(this)
                    .setContentTitle("New mail from " + "[email protected]")
                    .setContentText("Subject")
                    .setSmallIcon(R.drawable.icon)
                    .setContentIntent(pIntent)
                    .setAutoCancel(true)
                    .addAction(R.drawable.icon, "Call", pIntent)
                    .addAction(R.drawable.icon, "More", pIntent)
                    .addAction(R.drawable.icon, "And more", pIntent).build();


    NotificationManager notificationManager =
        (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    notificationManager.notify(0, n);

in above code setSmallIcon and setSmallIcon are for change the notification icon

Upvotes: 0

Estel
Estel

Reputation: 2204

For API < 11, the Notification constructor allowed an icon to be specified. For API > 10, the setSmallIcon and setLargeIcon methods for Notifcation.Builder allow much the same thing.

Upvotes: 6

Related Questions