user3013243 user3013243 - 1 year ago 156
Android Question

Android multiple line notification like Gmail app

I am trying to create a multiple line notification like the Gmail application does as shown in the image below (the 5 notifications grouped under one notification)

enter image description here

I have tried various examples but can only seem to create single notifications like

public void createSingleNotification(String title, String messageText, String tickerttext) {
int icon = R.drawable.notification_icon; // icon from resources
CharSequence tickerText = tickerttext; // ticker-text
long when = System.currentTimeMillis(); // notification time
Context context = getApplicationContext(); // application Context
CharSequence contentTitle = title; // expanded message title
CharSequence contentText = messageText; // expanded message text
Intent notificationIntent = new Intent(this, MainActivity.class);

Bundle xtra = new Bundle();
xtra.putString("title", title);
xtra.putString("message", messageText);

PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
notificationIntent, PendingIntent.FLAG_ONE_SHOT

NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
Notification notification = new Notification(icon, tickerText, when);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notification.defaults |= Notification.DEFAULT_LIGHTS;
notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.FLAG_AUTO_CANCEL;
notification.flags = Notification.DEFAULT_LIGHTS
| Notification.FLAG_AUTO_CANCEL;
final int HELLO_ID = 0;
mNotificationManager.notify(HELLO_ID, notification);

I am not sure how to create a notification group that I can add lines to.

Answer Source

You are looking for "Big View Style", like this:

enter image description here

Related documentation:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download