[null,null,["最后更新时间 (UTC):2025-08-17。"],[],[],null,["# Choose a client type\n\nThe Wear OS data layer APIs consist of several different types of clients, which\nare useful for different types of data and during different connectivity\nconditions.\n\nThis page introduces each client type, and it includes a table that compares the\ncapabilities of the different clients. Using this information, you can select\nthe set of client types that works best for your app.\n\nData client\n-----------\n\nA [`DataClient`](https://developers.google.com/android/reference/com/google/android/gms/wearable/DataClient) object lets you read or write to a [`DataItem`](https://developers.google.com/android/reference/com/google/android/gms/wearable/DataItem) or\n[`Asset`](https://developers.google.com/android/reference/com/google/android/gms/wearable/Asset):\n\n- Each `DataItem` is a unit of information that's broadcast and synchronized\n across all nearby devices that a user owns. A `DataItem` is stored persistently,\n and your device can read its contents until the data item is deleted.\n\n- An `Asset` is meant for larger data payloads, such as images or media files.\n\nMessage client\n--------------\n\nA [`MessageClient`](https://developers.google.com/android/reference/com/google/android/gms/wearable/MessageClient) object can send messages and is good for remote procedure\ncalls (RPC), such as using a Wear OS device to control the version of your app\nthat's installed on a handheld device.\n\nMessages are great for one-way requests using `sendMessage()`, or for a\nrequest-and-response communication model using `sendRequest()`. Unlike with data\nclients, message clients need the nodes to be connected to the network in order\nto send messages.\n\nThe `sendMessage()` method is a best effort to deliver to the remote node, and\nit doesn't contain any built-in retry mechanism. If the target device\ndisconnects before the network transfer starts, the method returns\n`TARGET_NODE_NOT_CONNECTED`.\n| **Note:** To help preserve power, consider sending messages only to nearby devices.\n\nChannel client\n--------------\n\nA [`ChannelClient`](https://developers.google.com/android/reference/com/google/android/gms/wearable/ChannelClient) object provides stream-oriented communication between\ndevices. A *channel* is a bidirectional communication pipe between two nodes,\nwhich is useful for use cases such as the following:\n\n- Transfer data files between two or more connected devices when the internet isn't available. `ChannelClient` saves disk space over `DataClient`, which creates a copy of the assets on the local device before synchronizing with connected devices.\n- Reliably send a file that's too large to send using a `MessageClient`.\n- Transfer streamed data, such as voice data from the microphone.\n\nAfter you open a channel, you can send and receive data in a continuous byte\nstream, rather than the discrete `DataItem` units that data clients require.\n\nYou're responsible for managing the data flow and keeping data consistent.\nChannel clients don't offer the same level of automatic data synchronization\nthat data clients do.\n\nClient comparison\n-----------------\n\nThe following table compares the capabilities of the different clients:\n\n| Client type | Data persistence | Supports data larger than 100 KB? | Network to use | Works offline? |\n|--------------------|--------------------------------------|--------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|------------------------------|\n| **Data client** | Data is persisted indefinitely | Yes (use [`Asset`](https://developers.google.com/android/reference/com/google/android/gms/wearable/Asset) objects) | Bluetooth preferred. Data is backed up to the cloud; if Bluetooth is available, this backup is done asynchronously | Yes, for both read and write |\n| **Message client** | No persistence and no retry | No | Bluetooth preferred, but can use Wi-Fi if it's the only type of connection available | No |\n| **Channel client** | No persistence (connection-oriented) | Yes | Bluetooth preferred, but can use Wi-Fi if it's the only type of connection available | No |"]]