I send couple notifications to the user and I use different notification ID for creating and notifying them and only one icon appears for all notifications. Everything is perfect. However when I swipe status bar to see notifications, it shows separated notifications.
As you see in the image I have two separated notifications, while I like to show them like telegram does (2 new messages). Does Android have something for that or I have to use a check previous notified messages and count unread notifications and show it as ContentText.
This is my code:
private final String GROUP_HEALTH = "HEALTH";
Random random = new Random();
int randInt = random.nextInt(9999 - 1000) + 1000;
int mNotificationId = randInt;
PendingIntent resultPendingIntent =
PendingIntent.getActivity(
mContext, 0,intent,
PendingIntent.FLAG_CANCEL_CURRENT
);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mContext);
mBuilder.setAutoCancel(true)
.setDefaults(Notification.DEFAULT_ALL)
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.drawable.ic_launcher)
.setTicker(mContext.getString(R.string.app_name))
.setContentTitle(title)
.setContentText(message)
.setContentIntent(resultPendingIntent)
.setGroup(GROUP_HEALTH)
.setContentInfo(notifType);
NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(mNotificationId, mBuilder.build());