Android Wear bundle notification and background image
I want to set up an android wear app that extends push notifications by stacking multiple notifications and then displaying different background images and actions on each stacked notification.
http://developer.android.com/training/wearables/notifications/stacks.html
This is what the stacked notifications look like, and then the cards in columns 2 and 3 will have unique background images.
I
can have the background images appear on individual notifications, but when I move to a stack of notifications, they don’t show.
Now does anyone know if this is feasible?
Sample code:
// Main Notification Object
NotificationCompat.Builder wearNotificaiton = new NotificationCompat.Builder(this)
.setDefaults(Notification.DEFAULT_ALL)
.setSmallIcon(R.drawable.icon)
.setWhen(System.currentTimeMillis())
.setTicker(title)
.setContentTitle(title)
.setContentText(text);
wearNotificaiton.setGroup(GROUP_ALARM_KEY);
Create second page
Notification TrendPage =
new NotificationCompat.Builder(this)
.setLargeIcon(trendImage)
.setStyle(new NotificationCompat.BigPictureStyle().bigPicture(trendImage))
.build();
Create third page
Notification ChartPage =
new NotificationCompat.Builder(this)
.setLargeIcon(trendImage)
.setStyle(new NotificationCompat.BigPictureStyle().bigPicture(trendImage))
.setContentTitle("test title 1")
.build();
wearable extender to add 2nd page and extend the main notification
NotificationCompat.Builder extendedNotification =
new NotificationCompat.WearableExtender()
.addPage(TrendPage)
.addPage(ChartPage)
.extend(wearNotificaiton)
.addAction(alertPageAction);
Solution
I
just played with this a little and I was afraid that it would be impossible to have different backgrounds in a group. It doesn’t matter if you only have one set of notifications or a set of notifications with pages – the entire stack has only one background.
If you disable setGroup
rows, everything will work fine in the background – you will have a different background on the first page.
By the way. To set a background for a specific notification, simply use WearableExtender
:
.extend(new NotificationCompat.WearableExtender().setBackground(trendImage))
Instead of applying largeIcon
or BigPictureStyle
. But this certainly doesn’t solve your problem with the group.