Android Wear捆绑通知和背景图片 [英] Android Wear Bundled Notifications and Background Images

查看:281
本文介绍了Android Wear捆绑通知和背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想安装扩展通过堆叠多个通知,然后在每个堆叠通知显示不同的背景图像和行动推送通知Android Wear应用程式。

http://developer.android.com/training/wearables/notifications/ stacks.html

这是堆叠的通知是什么样子,然后在第二和第三列卡将有独特的背景图像。

我可以得到背景图像显示在一个单一的通知,但是当我搬到堆放的通知,他们不露面。

有谁知道这是否可能在这个时候?

举例code ..

  //主要对象的通知
        NotificationCompat.Builder wearNotificaiton =新NotificationCompat.Builder(本)
                .setDefaults(Notification.DEFAULT_ALL)
                .setSmallIcon(R.drawable.icon)
                .setWhen(System.currentTimeMillis的())
                .setTicker(职称)
                .setContentTitle(职称)
                .setContentText(文本);        wearNotificaiton.setGroup(GROUP_ALARM_KEY);        //创建第二页
        通知TrendPage =
                新NotificationCompat.Builder(本)
                        .setLargeIcon(trendImage)
                        .setStyle(新NotificationCompat.BigPictureStyle()。bigPicture(trendImage))
                        。建立();        //创建第三页
        通知ChartPage =
                新NotificationCompat.Builder(本)
                        .setLargeIcon(trendImage)
                        .setStyle(新NotificationCompat.BigPictureStyle()。bigPicture(trendImage))
                        .setContentTitle(测试题1)
                        。建立();        //耐磨扩展来添加第二页,并延长主通知
        NotificationCompat.Builder extendedNotification =
                新NotificationCompat.WearableExtender()
                        .addPage(TrendPage)
                        .addPage(ChartPage)
                        .extend(wearNotificaiton)
                        .addAction(alertPageAction);


解决方案

我刚刚打了这样一点点,恐怕在一组具有不同的背景是根本不可能的。如果你只有一组页面的通知的通知或一组不要紧 - 只会有一个全栈背景

如果将禁用个setgroup 行一切都会很好地工作的背景 - 你将有第一页上不同的背景

BTW。要为特定的通知的背景只是利用 WearableExtender 的:

  .extend(新NotificationCompat.WearableExtender()的setBackground(trendImage))

而不是应用 largeIcon BigPictureStyle 。但是,这并不具有当然的群体解决您的问题。

I'd like to setup an android wear app that extends push notifications by stacking multiple notifications and then displaying different background images and action on each stacked notification.

http://developer.android.com/training/wearables/notifications/stacks.html

This is how the stacked notifications would look and then cards in the 2nd and 3rd columns would have unique background images.

I can get the background image to show up on a single notification, but when I moved to stacked notifications, they do not show up.

Does anyone know if this is possible at this time?

Example 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);

解决方案

I've just played with this a little bit and I'm afraid that having different backgrounds in one group is simply not possible. It doesn't matter if you have just a group of notifications or group of notifications with pages - there will be only one background for entire stack.
If you will disable the setGroup line everything will work fine with backgrounds - you will have different backgrounds on first page.

BTW. To set a background for particular notification just make use of WearableExtender:

    .extend(new NotificationCompat.WearableExtender().setBackground(trendImage))

instead of applying largeIcon or BigPictureStyle. But this doesn't solve your problem with groups of course.

这篇关于Android Wear捆绑通知和背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆