我想设置一个 Android Wear 应用程序,通过堆叠多个通知,然后在每个堆叠的通知上显示不同的背景图像和操作来扩展推送通知。
http://developer.android.com/training/wearables/notifications/stacks.html http://developer.android.com/training/wearables/notifications/stacks.html
这就是堆叠通知的外观,然后第二列和第三列中的卡片将具有独特的背景图像。
我可以让背景图像显示在单个通知上,但是当我移动到堆叠通知时,它们不会显示。
有谁知道目前这是否可能?
示例代码..
// 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);
我刚刚玩过一点,恐怕在一个小组中拥有不同的背景是根本不可能的。无论您只有一组通知还是一组带有页面的通知,都没有关系 - 整个堆栈只有一个背景。
如果您要禁用setGroup
线条一切都会与背景一起正常工作 - 您将在第一页上有不同的背景。
顺便提一句。要为特定通知设置背景,只需使用WearableExtender
:
.extend(new NotificationCompat.WearableExtender().setBackground(trendImage))
而不是申请largeIcon
or BigPictureStyle
。但这当然不能解决你的团体问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)