original source: https://developer.android.com/training/wearables/apps/index.html

Wearable Apps 개발의 기본

  • Watch apps use watch-specific APIs, where applicable (e.g., for circular layouts, wearable drawers, ambient mode, etc.).
  • Watch apps contain functionality appropriate to a watch.
  • Watch apps can access many standard Android APIs, but don’t support the following:
  1. android.webkit
  2. android.print
  3. android.app.backup
  4. android.appwidget
  5. android.hardware.usb

You can check if a watch supports a feature by calling hasSystemFeature() before using an API.

wearable app은 상황에 따라 두가지 모드로 들어갈수 있으며 두가지 모드를 다 지원하는 app을  always-on apps 이라고 한다. 

  • Interactive Use full color with fluid animation in this mode. The app is also responsive to input.
  • Ambient Render the screen with black and white graphics and do not present any input cues in this mode. This display mode is only supported on devices running Android 5.1 or higher.

original source : https://developer.android.com/training/wearables/notifications/compatibility.html

주의사항

  • Since a bridged notification needs to support both light (Wear1.x) and dark (Wear 2.0) backgrounds, We recommended that you don’t set color for bridged notifications. When Wear apps post local notifications, you can work around this by checking theAPI level of the device they’re running on and using an appropriate color for Wear 1.x and a different color for Wear 2.0.
  • Updated horizontal swipe gesture on a notification: To dismiss a notification in Wear 2.0, the user swipes horizontally in either direction. So if your notification instructs the user to swipe left or right, you must update the text of your notification.
  • Expanded notifications: To provide more information without requiring users to open your app on their phone, Wear 2.0 supports expanded notifications. So if you are currently using the addPage() method to provide additional text in your notification, you must update the code to useBigTextStyle in your expanded notification.

original source :https://developer.android.com/training/wearables/notifications/bridger.html#specifying-a-bridging-configuration-at-runtime

Bridging Mode for Notifications

handheld 기기와 wearable기기간에 공유되는 notification을 bridging notification이라고 한다.

개발자는 아래와 같은 방법으로 notification의 행동을 수정할수 있다.

  • Specifying a bridging configuration in the manifest file
  • Specifying a bridging configuration at runtime
  • Setting a dismissal ID so notification dismissals are synced across devices

Specifying a Bridging Configuration in the Manifest File

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

Specifying a Bridging Configuration at Runtime

create a BridgingConfig object and set it as shown in this section. manifest에서 정의된 것을 override한다.

BridgingManager.fromContext(context).setConfig(
 new BridgingConfig.Builder(context, false)
   .build());


Exempt notifications that are tagged

BridgingManager.fromContext(context).setConfig(
 new BridgingConfig.Builder(context, false)
   .addExcludedTags(Arrays.asList("foo", "bar", "baz"))
   .build());

      

           Setting a bridge tag

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
// ... set other fields ...
 .extend(
   new NotificationCompat.WearableExtender()
     .setBridgeTag("foo"));
 Notification notification = notificationBuilder.build();


Using a Dismissal ID to Sync Notification Dismissals

bridging mode를 수정하는 경우 여러기기들의 notification을 sync해야할 필요가 있는데 이를 수행하는 방법은 아래와 같다.

following methods of the NotificationCompat.WearableExtender class enable you to use dismissal IDs:

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

예시)

NotificationCompat.WearableExtender wearableExtender =
 new NotificationCompat.WearableExtender().setDismissalId("abc123");
Notification notification = new NotificationCompat.Builder(context)
// ... set other fields ...
 .extend(wearableExtender)
 .build();

Best Practices for Bridged Notifications

bridging notification이 전달되는 과정에 약간의 지연이 있음을 알고 wearable에 전달된 notification이 취소되고 그 와중에 사용자가 wearable에 전달된 notification을 클릭해서 반응한경우를 대비해야한다. 또 notification 여러개를 한번에 삭제하는 일이 없어야 한다.

Design Considerations

  • All notifications bridged from the paired phone to the Wear device use expanded notifications.
  • To learn when to use the different notification templates supported on Android Wear, read the Notifications patterns design guide.
  • To learn how to style your Wear notifications, read the Notifications style design guide.
  • If you have a chat messaging app, your notifications should use NotificationCompat.MessagingStyle. Wear uses the chat messages included in a MessagingStyle notification (see addMessage()) to provide a rich chat app-like experience in the expanded notification.
  • Add an inline action ( setHintDisplayActionInline(true)) within the notification stream to include a primary action that a user can quickly take on a notification. Examples of good use cases for an inline action within a notification stream include replying to a text message, stopping a fitnes activity, or archiving an email message.
  • Enable Smart Reply ( setAllowGeneratedReplies(true)) for your MessagingStyle notifications.