From d4ab053e3b25c5a5c2eeeedcaca0338d41e9bd98 Mon Sep 17 00:00:00 2001 From: Bert McMeen Date: Tue, 10 May 2016 17:15:19 -0700 Subject: [PATCH] docs: Bridger feature page for Wear preview Bug: 28561056 Change-Id: I2f28fb9bb456b443feee8925b42ef0884a6aa805 --- docs/html/wear/preview/features/bridger.jd | 147 +++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 docs/html/wear/preview/features/bridger.jd diff --git a/docs/html/wear/preview/features/bridger.jd b/docs/html/wear/preview/features/bridger.jd new file mode 100644 index 0000000000000..4f0d76b70c969 --- /dev/null +++ b/docs/html/wear/preview/features/bridger.jd @@ -0,0 +1,147 @@ +page.title=Bridging Mode for Notifications +meta.keywords="wear-preview" +page.tags="wear-preview" +page.image=images/cards/card-n-sdk_2x.png +@jd:body + +
+ +
+ +

+ By default, notifications are bridged + (shared) from an app on a companion phone to the watch. Standalone + Android Wear apps are planned for Android Wear 2.0. Therefore, a phone + app and a standalone watch app may be sources of the same notifications. + The Android Wear 2.0 Preview includes a Bridging mode feature to handle + this problem of duplicate notifications. +

+ +

+ With the Android Wear 2.0 Preview, developers can plan to change the + behavior of notifications with the following: +

+ + + +

+ Preventing Bridging with the Bridging Mode Feature +

+ +

+ To prevent bridging of notifications from a phone app, you can use a + entry in the manifest file of the watch app (e.g. the standalone watch + app), as follows: +

+ +
+com.google.android.wearable.notificationBridgeMode
+
+

+ Setting that entry to NO_BRIDGING will prevent bridging: +

+ +
+<meta-data android:name="com.google.android.wearable.notificationBridgeMode"
+                   android:value="NO_BRIDGING" />
+
+

+ The default bridging behavior occurs if you do not include the entry or + if you specify a value of BRIDGING instead of + NO_BRIDGING. +

+ +

+ Existing method of preventing bridging +

+ +

+ An existing way to prevent bridging is with the + Notification.Builder class; specify true in the + + setLocalOnly method. +

+ +

+ However, this way to prevent bridging may not be preferable. For example, + if a user installs a phone app but not the corresponding watch app, the + setLocalOnly method could prevent the bridging of helpful + notifications. Additionally, users may have multiple paired watches and + the watch app may not be installed on all of them. +

+ +

+ Thus, if bridging should be prevented when the watch app + is installed, use the Bridging mode + feature. +

+ +

+ Using a Dismissal ID to Sync Notification Dismissals +

+ +

+ If you prevent bridging with the Bridging mode feature, dismissals + (cancellations) of notifications are not synced across a user's devices. + However, the following methods of the + NotificationCompat.WearableExtender class enable you to use dismissal + IDs: +

+ +
+public WearableExtender setDismissalId(String dismissalId)
+public String getDismissalId()
+
+

+ To enable a dismissal to be synced, use the setDismissalId() + method. For each notification, pass a globally unique ID, as a string, + when you call the setDismissalId() method. When the + notification is dismissed, all other notifications with the same + dismissal ID are dismissed on the watch(es) and on the companion phone. + To retrieve a dismissal ID, use getDismissalId(). +

+ +

+ In the following example, syncing of dismissals is enabled because a + globally unique ID is specified for a new notification: +

+ +
+NotificationCompat.WearableExtender wearableExtender =
+new NotificationCompat.WearableExtender().setDismissalId(“abc123”);
+Notification notification = new NotificationCompat.Builder(context)
+<set other fields>
+.extend(wearableExtender)
+.build();
+
+

+ Dismissal IDs work if a watch is paired to an Android phone, but not if a + watch is paired to an iPhone. +