如何在偷看定制的Andr​​oid耐磨通知添加一个图标? [英] How to add an icon on a peeking custom android wearable notification?

查看:267
本文介绍了如何在偷看定制的Andr​​oid耐磨通知添加一个图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的自定义通知只显示标题(或文字内容,如果标题丢失)时,它的偷看。试图设置在根通知图标没有效果。如果我设置在扩展器通知图标它显示,但偷看通知是如此之小(显然,其高度被装配到一个衬里标题/描述的高度),该图标不会配合。相比于例如电子邮件通知窥测通知的高度要小得多。

这里的code我试图运行的轮廓:

 意图notificationIntent =新意图(这一点,CustomNotification.class);
的PendingIntent notificationPendingIntent = PendingIntent.getActivity(这一点,0,
    notificationIntent,
    PendingIntent.FLAG_UPDATE_CURRENT);通知通知=新Notification.Builder(本)
                .setContentTitle(测试)
                .setSmallIcon(R.mipmap.ic_launcher)
                .extend(新Notification.WearableExtender()
                                .setDisplayIntent(notificationPendingIntent)
                                .setCustomSize preSET(Notification.WearableExtender.SIZE_FULL_SCREEN)
                )
                。建立();


解决方案

您可能会运行到这一事实,你有过很难控制如何通知显示,而在偷看视图:

注意:当该通知在主屏幕上偷看,该系统与它从通知的语义数据生成一个标准的模板,它显示这个模板行之有效所有watchfaces当用户刷卡的通知后,他们会。然后看到通知的自定义活动。

https://developer.android.com/training/wearables/应用程序/ layouts.html#UiLibrary

Our custom notification only shows title (or content text if title is missing) when it's peeking. Trying to set the icon on the root notification has no effect. If I set the icon on the extender notification it shows, but the peeking notification is so small (obviously, its height is fitted to the height of the one liner title/description) that the icon wont fit. In comparison to e.g. an email notification the height of the peeking notification is much smaller.

Here's the outline of the code I'm trying to run:

Intent notificationIntent = new Intent(this, CustomNotification.class);
PendingIntent notificationPendingIntent = PendingIntent.getActivity(this, 0,
    notificationIntent,
    PendingIntent.FLAG_UPDATE_CURRENT);

Notification notification = new Notification.Builder(this)
                .setContentTitle("Test")
                .setSmallIcon(R.mipmap.ic_launcher)
                .extend(new Notification.WearableExtender()
                                .setDisplayIntent(notificationPendingIntent)
                                .setCustomSizePreset(Notification.WearableExtender.SIZE_FULL_SCREEN)
                )
                .build();

解决方案

You may be running into that fact that you have very little control over how the notification displays while in peek-view:

"Note: When the notification is peeking on the homescreen, the system displays it with a standard template that it generates from the notification's semantic data. This template works well on all watchfaces. When users swipe the notification up, they'll then see the custom activity for the notification."

https://developer.android.com/training/wearables/apps/layouts.html#UiLibrary

这篇关于如何在偷看定制的Andr​​oid耐磨通知添加一个图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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