Steve
Steve

Reputation: 55555

Android Wear Specific Notification

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?

Upvotes: 12

Views: 1477

Answers (5)

Vintesh
Vintesh

Reputation: 1697

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.

Upvotes: 0

Janusz
Janusz

Reputation: 189444

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.

Upvotes: 1

Eliezer
Eliezer

Reputation: 7347

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.

Upvotes: 2

Mark Renouf
Mark Renouf

Reputation: 30990

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)));

Upvotes: 2

Johnny505
Johnny505

Reputation: 221

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();

Upvotes: 2

Related Questions