コンテンツに移動

よくアクセスするページ

最近アクセスしたページ

navigation

Sending and Syncing Data on Wear

On this page

With Wear OS by Google, a watch can communicate with a network directly, without access to an Android or iOS phone.

This page has the following dependencies and prerequisites:

Separately, the Wearable Data Layer API, which is part of Google Play services, provides an optional communication channel for apps. Although a Wear app can communicate with a phone app using the Wearable Data Layer API, connecting to a network using this API is discouraged.

The Data Layer API consists of a set of data objects that the system can send and synchronize, along with listeners that notify apps of certain events, as follows:

Data Item
A DataItem provides data storage with automatic syncing between the handheld and wearable.
Asset
Asset objects are for sending binary blobs of data, such as images. You attach assets to data items and the system automatically takes care of the transfer for you, conserving Bluetooth bandwidth by caching large assets to avoid re-transmission.
Message
A MessageClient can send messages and is good for remote procedure calls (RPC), such as controlling a handheld's media player from the wearable or starting an intent on the wearable from the handheld. Messages are also great for one-way requests or for a request/response communication model. If the handheld and wearable are connected, the system queues the message for delivery and returns a successful result code. If the devices are not connected, an error is returned. A successful result code does not indicate that the message was delivered successfully as the devices may disconnect after receiving the result code.
Channel
You can use a ChannelClient to transfer large entities, such as music and movie files, from a handheld to a wearable device. Using a ChannelClient for data transfer has the following benefits:
  • Transfer large data files between two or more connected devices, without the automatic synchronization provided when using Asset objects attached to DataItem objects. ChannelClient saves disk space over DataClient, which creates a copy of the assets on the local device before synchronizing with connected devices.
  • Reliably send a file that is too large to send using a MessageClient.
  • Transfer streamed data, such as music pulled from a network server or voice data from the microphone.
WearableListenerService (for services)
Extending WearableListenerService lets you listen for important data layer events in a service. The system manages the lifecycle of the WearableListenerService, binding to the service when it needs to send data items or messages and unbinding the service when no work is needed.
OnDataChangedListener (for foreground activities)
Implementing OnDataChangedListener in an activity lets you listen for important data layer events when an activity is in the foreground. Using this instead of the WearableListenerService lets you listen for changes only when the user is actively using your app.

Warning: Because these APIs are designed for communication between handhelds and wearables, these are the only APIs you should use to set up communication between these devices. For instance, don't try to open low-level sockets to create a communication channel.

Important: Your phone and Wear APK signatures and the signature schemes must to be identical for the DataLayer API to be able to successfully communicate between devices. This includes your usage of the v1 and/or v2 signature. Ensure the signature scheme is set correctly in build.gradle or when you use the Generate Signed APK wizard.

Wear OS supports multiple wearables connected to a handheld device. For example, when the user saves a note on a handheld, it automatically appears on all of the user's Wear devices. To help synchronize data between devices, Google’s servers host a cloud node in the network of devices. The system synchronizes data to directly connected devices, the cloud node, and to wearable devices connected to the cloud node via Wi-Fi.

Figure 1. A sample network of nodes with handheld and wearable devices.

Lessons

Network Access and Syncing
This lesson shows you how to acquire a high-bandwidth network. The lesson also provides a starting point for cloud messaging and more.
Accessing the Wearable Data Layer
This lesson shows you how to create a client to access the Data Layer APIs.
Syncing Data Items
Data items are objects that are stored in a replicated data store that is automatically synced from handhelds to wearables.
Transferring Assets
Assets are binary blobs of data that you typically use to transfer images or media.
Sending and Receiving Messages
Messages are designed for fire-and-forget messages that you can send back and forth between the wearable and handheld.
Handling Data Layer Events
Be notified of changes and events to the data layer.
Migrating Wear Apps to GoogleApi
Migrate away from the GoogleApiClient class.
このサイトでは、ユーザーが選択したサイトの言語と表示設定を保存する目的で Cookie を使用しています。

Android デベロッパー向けの最新情報やヒントを入手して、Google Play での成功を手に入れましょう。

* 必須

送信しました

WeChat で Google Developers をフォローする

このサイトをで表示しますか?

ページの表示言語としてを選択しましたが、このサイトの言語はに設定されています。

言語設定を変更してこのサイトをで表示しますか?言語設定を変更する場合は、各ページの下にある言語メニューを使用してください。

このクラスには、API レベル 以上が必要です。

API レベル が選択されているため、このドキュメントは非表示になっています。左のナビゲーションの上にあるセレクタを使って、ドキュメントの API レベルを変更できます。

アプリに必要な API レベルを指定する方法について、詳しくは異なるプラットフォーム バージョンのサポートをご覧ください。

Take a short survey?
Help us improve the Android developer experience. (April 2018 — Developer Survey)