如何显示来自 Android wear watchface 的通知

How to show notification from Android wear watchface

我正在尝试显示来自我的表盘的通知,因为我想在用户首次打开表盘时显示其他信息。

这类似于 LG G Watch R 安装的 GMT 表盘,要求用户向左滑动到 select 时区。

这段代码似乎对我不起作用:

  Notification.Builder builder = new Notification.Builder(context)
                .setContentTitle("Title")
                .setContentText("Content");

        ((NotificationManager) getSystemService(NOTIFICATION_SERVICE))
                .notify(1, builder.build());

这是从 Android wear 的示例之一复制而来的(未在表盘示例中使用,只是一个常规的 wear 应用程序)

您很可能缺少图标,您需要为 Android 指定图标以显示您的通知。尝试指定文档中示例提到的所有内容:

Notification noti = new Notification.Builder(mContext)
         .setContentTitle("New mail from " + sender.toString())
         .setContentText(subject)
         .setSmallIcon(R.drawable.new_mail)
         .setLargeIcon(aBitmap)
         .build();