I have a some troubles with understanding of goal of setGroup()
method.
As docs said :
...Grouped notifications may display in a cluster or stack on devices which support such rendering....
Here it is the first question :
What it is this rendering? What's so special about it?!
I create a method which show a custom text message :
public static void showNotification(Context context, String title, String message, PendingIntent pendingIntent) {
notificationMessages.add(message);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setContentTitle(title)
.setContentText(message)
.setAutoCancel(true)
// .setGroupSummary(true)
.setSmallIcon(R.drawable.ic_launcher)
.setContentInfo("" + (notificationMessages.size()))
/*.setGroup(++i + "")*/;
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
inboxStyle.setBigContentTitle(title);
for (int i = 0; i < notificationMessages.size(); i++) {
inboxStyle.addLine(notificationMessages.get(i));
}
builder.setContentIntent(pendingIntent);
builder.setStyle(inboxStyle);
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = builder.build();
mNotificationManager.notify(0, notification);
}
and play with notificationID
, setGroup
and setGroupSummary
methods.
public static void showNotification(Context context, String title, String message, PendingIntent pendingIntent) {
notificationMessages.add(message);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setContentTitle(title)
.setContentText(message)
.setAutoCancel(true)
// .setGroupSummary(true)
.setSmallIcon(R.drawable.ic_launcher)
.setContentInfo("" + (notificationMessages.size()))
.setGroup(GROUP_KEY);
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
inboxStyle.setBigContentTitle(title);
for (int i = 0; i < notificationMessages.size(); i++) {
inboxStyle.addLine(notificationMessages.get(i));
}
builder.setContentIntent(pendingIntent);
builder.setStyle(inboxStyle);
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = builder.build();
mNotificationManager.notify(new Random().nextInt(3), notification);
}
But, no visual changes comes if I commented lines or not. So here is a stuck for me in understanding of purpose of this method.