12

The WearableNotifications.Builder setLocalOnly method can be used for displaying a notification on a phone only, and not mirror it to a Wear device.

Is there a way to do the opposite, so creating a notification that will display only on the Wear device?

4

5 回答 5

2

没有办法指定不应在本地显示整个通知。然而,最终的通知扩展 API(6/25 发布),有一种方法可以指定只能出现在可穿戴设备上的操作。

为此,请添加包装在 WearableExtender 中的操作:

NotificationCompat.Builder builder = new NotificationCompat.Builder();
builder.extend(new NotificationCompat.WearableExtender()
    .addAction(new NotificationCompat.Action(
        R.drawable.reply, "Reply", pendingIntent)));
于 2014-06-27T04:28:30.707 回答
2

对于Android Wear Developers Google+ 页面上的这个问题的官方 SDK :

您可以在可穿戴设备上使用与在手机上使用的通知 API 相同的通知 API,方法是编写一个 Android Wear 应用程序。如果您需要从手机触发该通知,您可以使用 Google Play 服务中的 Wearable api 发送消息来触发它们。</p>

于 2014-07-06T14:44:35.473 回答
2

实际上,您可以在可穿戴通知上使用.setMinPriority()来做到这一点(虽然它不是官方的,但现在可以使用)

 Notification summaryNotification = new WearableNotifications.Builder(builderG)
        .setGroup(GROUP_KEY_MESSAGES, WearableNotifications.GROUP_ORDER_SUMMARY)
        .setMinPriority() 
        .build();
于 2014-06-10T15:14:20.690 回答
1

有一个技巧可以仅为穿戴设备添加通知。

使用NotificationCompat.Builder.setGroup将通知添加到组,并且不显示该组的摘要通知。手机只会显示摘要通知,因为手机上没有显示任何内容。只需为每个只应在手机上显示的通知创建一个随机组字符串。

于 2014-08-30T15:06:54.143 回答
0

通知仅通过手持设备驱动,因此为了仅在佩戴时显示通知,只有一种可能的方式来拦截可穿戴设备上的通知,然后只需向可穿戴设备发送消息以生成不为手持设备生成的通知。这些步骤可以提供帮助。

于 2014-08-31T19:38:20.140 回答