Before creating a custom notification, you must create a group notification. Similar:
NotificationCompat.Builder groupBuilder = new NotificationCompat.Builder(context) .setContentTitle(title) .setContentText(content) .setGroupSummary(true) .setGroup("GROUP_1") .setStyle(new NotificationCompat.BigTextStyle().bigText(content)) .setContentIntent(pendingIntent);
Do not forget setGroupSummary to true.
Then create a child notification that the group value matches the value of groupBuilder . Here is "GROUP_1".
NotificationCompat.Builder builder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_stat_communication_invert_colors_on) .setContentTitle(title) .setContentText(content) .setGroup("GROUP_1") .setStyle(new NotificationCompat.BigTextStyle().bigText(content)) .setContentIntent(pendingIntent)
Finally, use NoticationManagerCompat to notify them.
NotificationManagerCompat manager = NotificationManagerCompat.from(context); manager.notify(GROUP_ID, groupBuilder.build()); manager.notify(id, builder.build());
chenupt
source share