Android Wear Specific Notification

前端 未结 5 2042
醉话见心
醉话见心 2021-02-13 23:21

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 th

相关标签:
5条回答
  • 2021-02-13 23:28

    There is no way to specify an entire notification should not be displayed locally. However, the final notification extensions API (released 6/25), there is a way to specify actions which should only appear on a wearable.

    To do this, add the actions wrapped in a WearableExtender:

    NotificationCompat.Builder builder = new NotificationCompat.Builder();
    builder.extend(new NotificationCompat.WearableExtender()
        .addAction(new NotificationCompat.Action(
            R.drawable.reply, "Reply", pendingIntent)));
    
    0 讨论(0)
  • 2021-02-13 23:29

    For the official SDK as per this question on Android Wear Developers Google+ page:

    You can use the same notification APIs on the wearable that you use on a phone by writing an android wear app. If you need to trigger that notification from the phone, you can use the Wearable apis in Google Play Services to send messages to trigger them.

    0 讨论(0)
  • 2021-02-13 23:36

    Notification drives through Handheld only, So in order to just show Notification on wear only a possible way to intercept Notification on Wearable then just send message to Wearable for Generating Notificaiton don't generate for Handheld. These steps can help.

    0 讨论(0)
  • 2021-02-13 23:39

    Actually you can do it using .setMinPriority() on the wearable notification (while it's not official, it works for now)

     Notification summaryNotification = new WearableNotifications.Builder(builderG)
            .setGroup(GROUP_KEY_MESSAGES, WearableNotifications.GROUP_ORDER_SUMMARY)
            .setMinPriority() 
            .build();
    
    0 讨论(0)
  • 2021-02-13 23:48

    There is a trick to add a notification for the wear device only.

    Add the notification to a group with NotificationCompat.Builder.setGroup and don't display a summary notification for this group. The phone will only display the summary notifications, since there isn't one nothing is displayed on the phone. Just create a random group string for every notification that should only be displayed on the phone.

    0 讨论(0)
提交回复
热议问题