I was playing with stacked notifications but I can't make it work, the notifications don't fire at all. Here's the code:
private void sendSimpleStackedNotifications() {
NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender()
.setBackground(BitmapFactory.decodeResource(getResources(), R.drawable.notif_background));
for (int i = 0; i < 5; i++) {
...
}
}
Inside the for
loop I have:
Version 1:
Notification n = new NotificationCompat.Builder(this)
.setContentTitle("New notification!")
.setContentText("Notification nº" + (i + 1))
.extend(wearableExtender)
.setGroup(GROUP)
.build();
mNotificationManager.notify(i, n);
Version 2:
NotificationCompat.Builder nb = new NotificationCompat.Builder(this)
.setContentTitle("New notification!")
.setContentText("Notification nº" + (i + 1))
.extend(wearableExtender)
.setGroup(GROUP);
mNotificationManager.notify(i, nb.build());
But none of the approaches work. What am I missing?
EDIT: Thanks to user aiur I've found what I was missing:
.setSmallIcon()
Now the notifications are correctly shown but I have a problem, they are not grouped in the hand-held device even if I add (in both Version 1 and Version 2):
.setGroup(GROUP)
.setGroupSummary(true)
In the wearable they are correctly stacked.
Any idea why?
Thanks.