Android: notificações e resumo agrupados ainda mostrados separadamente no 4.4 e abaixo
Eu quero implementarnotificações empilhadas no Android Wear Para isso, crio 1 notificação resumida e N notificações individuais para cada "item". Quero que apenas o resumo seja mostrado no telefone. Aqui está o meu código:
private void showNotifications() {
NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
showNotification1(notificationManager);
showNotification2(notificationManager);
showGroupSummaryNotification(notificationManager);
}
private void showNotification1(NotificationManager notificationManager) {
showSingleNotification(notificationManager, "title 1", "message 1", 1);
}
private void showNotification2(NotificationManager notificationManager) {
showSingleNotification(notificationManager, "title 2", "message 2", 2);
}
protected void showSingleNotification(NotificationManager notificationManager,
String title,
String message,
int notificationId) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setContentTitle(title)
.setContentText(message)
.setSmallIcon(R.mipmap.ic_launcher)
.setGroupSummary(false)
.setGroup("group");
Notification notification = builder.build();
notificationManager.notify(notificationId, notification);
}
private void showGroupSummaryNotification(NotificationManager notificationManager) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setContentTitle("Dummy content title")
.setContentText("Dummy content text")
.setStyle(new NotificationCompat.InboxStyle()
.addLine("Line 1")
.addLine("Line 2")
.setSummaryText("Inbox summary text")
.setBigContentTitle("Big content title"))
.setNumber(2)
.setSmallIcon(R.mipmap.ic_launcher)
.setCategory(Notification.CATEGORY_EVENT)
.setGroupSummary(true)
.setGroup("group");
Notification notification = builder.build();
notificationManager.notify(123456, notification);
}
Isso funciona muito bem no Android 5.1, apenas o resumo é mostrado na barra de notificação do telefone:
Mas no Android 4.4, também mostra as notificações individuais 1 e 2:
Nos dois casos, as notificações no Android Wear são mostradas em uma pilha, conforme desejado. Como faço para o Android 4.4 mostrar apenas a notificação resumida na barra de notificações?