Mark023
Mark023

Reputation: 105

Android display multiple messages in a single notification

Currently, I receive notifications from a server. What happens is, if I get a notification, I dont see it for long time. When a new notification comes, I lose the previous one. I want a single notification with multiple messages something like this -

enter image description here

Upvotes: 1

Views: 1049

Answers (1)

Ravi
Ravi

Reputation: 35539

It is InboxStyle notification

Notification notif = new Notification.Builder(mContext)
 .setContentTitle("5 New mails from " + sender.toString())
 .setContentText(subject)
 .setSmallIcon(R.drawable.new_mail)
 .setLargeIcon(aBitmap)
 .setStyle(new Notification.InboxStyle()
     .addLine(str1)
     .addLine(str2)
     .setContentTitle("")
     .setSummaryText("+3 more"))
 .build();

Here is official document

check this example also - Inbox Style Notification Like Whatsapp

Upvotes: 3

Related Questions