تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تتألف واجهات برمجة التطبيقات لطبقة البيانات في Wear OS من عدة أنواع مختلفة من العملاء، والتي
تكون مفيدة لأنواع مختلفة من البيانات وخلال مختلف شروط اتصال
الشبكة.
تعرِض هذه الصفحة كل نوع من أنواع العملاء، وتتضمّن جدولاً يقارن بين
إمكانات العملاء المختلفة. باستخدام هذه المعلومات، يمكنك اختيار
مجموعة أنواع العملاء التي تناسب تطبيقك على أفضل نحو.
كل DataItem هو وحدة معلومات يتم بثها ومزامنتها
على جميع الأجهزة القريبة التي يملكها المستخدم. يتم تخزين DataItem بشكل دائم،
ويمكن لجهازك قراءة محتواه إلى أن يتم حذف عنصر البيانات.
يُستخدَم Asset مع الحمولات الأكبر حجمًا من البيانات، مثل الصور أو ملفات الوسائط.
برنامج بريد إلكتروني
يمكن لعنصر MessageClient إرسال الرسائل وهو مناسب لطلبات الإجراء عن بُعد (RPC)، مثل استخدام جهاز Wear OS للتحكّم في إصدار تطبيقك المُثبَّت على جهاز محمول باليد.
تُعدّ الرسائل رائعة للطلبات أحادية الاتجاه باستخدام sendMessage()، أو لتطبيق sendRequest() لنموذج تواصل يعتمد على الطلب والاستجابة. على عكس برامج معالجة البيانات، تحتاج برامج معالجة الرسائل إلى ربط العقد بالشبكة من أجل إرسال الرسائل.
إنّ طريقة sendMessage() هي أفضل جهد لإرسال البيانات إلى العقدة البعيدة،
ولا تحتوي على أيّ آلية مضمّنة لإعادة المحاولة. إذا انقطع اتصال الجهاز المستهدَف
قبل بدء عملية النقل عبر الشبكة، تُعرِض الطريقة TARGET_NODE_NOT_CONNECTED.
عميل القناة
يقدّم عنصر ChannelClient إمكانية التواصل بين
الأجهزة من خلال البث. القناة هي قناة تواصل ثنائية الاتجاه بين عقدتَين،
وهي مفيدة لحالات الاستخدام التالية:
نقل ملفات البيانات بين جهازَين أو أكثر متصلَين عندما لا يكون الإنترنت
متاحًا توفّر ميزة ChannelClient مساحة على القرص تزيد عن DataClient، ما يؤدي إلى
إنشاء نسخة من مواد العرض على الجهاز المحلي قبل مزامنتها مع
الأجهزة المتصلة.
إرسال ملف كبير جدًا لا يمكن إرساله باستخدام MessageClient
نقل البيانات التي يتم بثها، مثل البيانات الصوتية من الميكروفون
بعد فتح قناة، يمكنك إرسال البيانات واستلامها في بث بايت متواصل، بدلاً من استخدام وحدات DataItem المنفصلة التي تتطلّبها برامج البيانات.
تكون أنت المسؤول عن إدارة تدفق البيانات والحفاظ على اتساقها.
لا يوفّر عملاء القنوات المستوى نفسه من مزامنة البيانات التلقائية مقارنةً بعملاء البيانات.
يُفضَّل استخدام البلوتوث. يتم الاحتفاظ بنسخة احتياطية من البيانات على السحابة الإلكترونية، وإذا كان البلوتوث
متوفرًا، يتم إجراء هذا الإجراء بشكل غير متزامن.
نعم، لكل من القراءة والكتابة
برنامج بريد إلكتروني
لا تُستخدَم ميزة الاحتفاظ بالبيانات ولا إعادة المحاولة.
لا
يُفضَّل استخدام البلوتوث، ولكن يمكن استخدام Wi-Fi إذا كان هو النوع الوحيد من
الاتصال المتاح
لا
عميل القناة
لا تتوفّر ميزة الاحتفاظ بالبيانات (الطلبات الموجَّهة للاتصال)
نعم
يُفضَّل استخدام البلوتوث، ولكن يمكن استخدام Wi-Fi إذا كان هو النوع الوحيد من
الاتصال المتاح
لا
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-08-17 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 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 |"]]