首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通知操作图标未显示在可穿戴设备上

通知操作图标未显示在可穿戴设备上
EN

Stack Overflow用户
提问于 2016-05-20 08:49:51
回答 1查看 656关注 0票数 3

我试图在通知中添加一个动作,并在可穿戴设备上显示动作按钮。下面的代码显示了如何创建一个操作并将其添加到NotificationCompat中,该操作将使用NotificationManagerCompat交付,如下所示:https://developer.android.com/training/wearables/notifications/creating.html#Deliver

代码语言:javascript
复制
    NotificationCompat.Action declineActionDark = new NotificationCompat.Action(R.drawable.done_black, getString(R.string.accept), acceptInvitationPendingIntent);
    NotificationCompat.Action acceptActionDark = new NotificationCompat.Action(R.drawable.clear_black, getString(R.string.decline), declineInvitationPendingIntent);
    NotificationCompat.Action declineActionLight = new NotificationCompat.Action(R.drawable.done_white, getString(R.string.accept), acceptInvitationPendingIntent);
    NotificationCompat.Action acceptActionLight = new NotificationCompat.Action(R.drawable.clear_white, getString(R.string.decline), declineInvitationPendingIntent);

    NotificationCompat.WearableExtender wearableExtender =
            new NotificationCompat.WearableExtender()
                    .addAction(declineActionLight)
                    .addAction(acceptActionLight);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    Notification notification = new NotificationCompat.Builder(getApplicationContext())
            .setContentTitle(getApplicationContext().getResources().getString(R.string.app_name))
            .setContentText(message)
            .setSound(defaultSoundUri)
            .setSmallIcon(R.drawable.place_white)
            .setLargeIcon(bitmap)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(message))
            .addAction(declineActionDark)
            .addAction(acceptActionDark)
            .setAutoCancel(true)
            .setPriority(Notification.PRIORITY_HIGH)
            .extend(wearableExtender)
            .build();
    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(getApplicationContext());
    notificationManager.notify(notificationId, notification);

正如你所看到的,我使用两种不同的图像,一个暗的和一个光的检查标记和下降图像。这是因为我希望在我的Marshmallow测试设备的亮通知区域有一个暗图像,在可穿戴操作按钮的相当黑暗的背景中有一个光线图像。

这里的问题是,可穿戴设备根本不显示图标。请参阅运行Android6.0.1的可穿戴硬件的以下屏幕截图:

在现实中,没有黑角。这似乎是安卓穿戴屏幕截图工具的一个错误。但是,我想在动作按钮上显示图标。作为项目中的所有可绘图,done_white/_black和clear_white/黑色都是矢量可绘制的。我已经试过用PNG作为抽屉,但它们也不起作用。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-06-28 13:14:30

我也有同样的问题,因为我使用SVG文件。当我把它改成PNG时,它就开始工作了。

解决方案:使用PNG代替向量SVG

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37342157

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档