يمكنك الانضمام إلى
قائمتنا البريدية للحصول على تحديثات وإعلانات عن الأجهزة المجاورة.
نظرة عامة
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
Nearby Connections هي واجهة برمجة تطبيقات للشبكات من نظير إلى نظير تتيح للتطبيقات بسهولة رصد الأجهزة المجاورة والاتصال بها وتبادل البيانات معها في الوقت الفعلي، بغض النظر عن إمكانية الاتصال بالشبكة.
في ما يلي بعض الأمثلة على حالات الاستخدام:
- لوح المعلومات التعاوني: يمكنك تدوين الأفكار مع المشاركين القريبين على لوح معلومات افتراضي مشترك.
- ألعاب اللاعبين المتعدّدين على الشبكة المحلية: يمكنك إعداد لعبة متعددة اللاعبين ودعوة مستخدمين آخرين قريبين للانضمام إليها.
- الألعاب على شاشات متعددة: يمكنك استخدام هاتف أو جهاز لوحي كوحدة تحكّم في الألعاب لتشغيل الألعاب المعروضة على جهاز Android بشاشة كبيرة قريب، مثل Android TV.
- نقل الملفات بلا إنترنت: يمكنك مشاركة الصور أو الفيديوهات أو أي نوع آخر من البيانات بسرعة وبدون الحاجة إلى الاتصال بشبكة.
مقدمة
تتيح Nearby Connections الإعلان عن الأجهزة المجاورة واكتشافها والربط بينها بطريقة كاملة بلا إنترنت من جهاز إلى جهاز. تتميز عمليات الربط بين الأجهزة بمعدّل نقل بيانات عالٍ ووقت استجابة منخفض وتشفير كامل لإتاحة عمليات نقل بيانات سريعة وآمنة.
الهدف الأساسي من واجهة برمجة التطبيقات هذه هو توفير منصة بسيطة وموثوقة وفعّالة. تستخدم واجهة برمجة التطبيقات مزيجًا من تقنيات البلوتوث والبلوتوث منخفض الطاقة وWi-Fi، ما يتيح الاستفادة من مزايا كل تقنية وتجنُّب عيوبها. ويؤدي ذلك إلى تجريد فعّال لتقلبات Bluetooth وWi-Fi على مجموعة من الأنظمة الأساسية وإصدارات نظام التشغيل، ما يتيح للمطوّرين التركيز على الميزات التي تهم المستخدمين.
نظرة عامة على واجهة برمجة التطبيقات
ينقسم استخدام واجهة برمجة التطبيقات إلى مرحلتين: مرحلة ما قبل الاتصال ومرحلة ما بعد الاتصال.
في مرحلة ما قبل الاتصال، يعلن المعلِنون عن أنفسهم، بينما يكتشف الباحثون المعلِنين القريبين ويرسلون طلبات اتصال. يبدأ طلب الربط
من جهاز "الباحث" إلى جهاز "المعلن" عملية مصادقة متماثلة
تؤدي إلى قبول (أو رفض) طلب الربط
من كلا الجهازين بشكل مستقل.
بعد قبول طلب الاتصال من كلا الطرفين، يُعد الاتصال قد تم إنشاؤه، وتنتقل الأجهزة إلى مرحلة ما بعد الاتصال، حيث يمكن لكلا الطرفين تبادل البيانات.
الإعلان واقتراح المحتوى
سيصبح المعلِنون مرئيين للمستخدمين الآخرين الذين يشاركون في عملية الاكتشاف، وسيتم إشعار هؤلاء المستخدمين عند العثور على معلِن جديد أو فقدانه.
إنشاء روابط
عندما يريد مستخدم اكتشاف الربط بمعلِن قريب، يمكنه طلب الربط.
سيتم إشعار الطرفين بعملية بدء الاتصال، وسيكون بإمكان كليهما قبول الاتصال أو رفضه.
بعد أن يردّ الطرفان، سيتم إعلام كل منهما بالنتيجة. إذا وافق الطرفان على الربط، سيتم اعتبار عملية الربط مكتملة، ويمكن حينئذٍ بدء نقل البيانات.
تبادل البيانات
بعد إنشاء اتصال، يصبح استخدام واجهة برمجة التطبيقات متماثلاً، وبالتالي لا يعود هناك فرق بين "المُعلِن" و"المكتشف".
يمكن للطرفَين الآن تبادل البيانات. هناك 3 أنواع من الحمولة المتوافقة:
- وحدات البايت: مصفوفات البايت محدودة بـ 32 ألف بايت، وهي مناسبة لإرسال عناصر مثل البيانات الوصفية أو رسائل التحكّم.
- الملف: ملفات بأي حجم، ويتم نقلها من التطبيق إلى واجهة الشبكة مع الحد الأدنى من النسخ عبر حدود العمليات.
- البث: هو بث للبيانات يتم إنشاؤه في الوقت الفعلي، كما هو الحال مع الصوت/الفيديو المسجّل، بدون معرفة الحجم النهائي مسبقًا.
سيتم إعلام المستلِمين بالبيانات الواردة الجديدة وأي إشعارات بشأن مستوى التقدّم أو عمليات الإلغاء أو المشاكل.
تكون عمليات الربط التي يتم إنشاؤها مزدوجة الاتجاه، ما يعني أنّه يمكن للمعلِنين والمكتشفين إرسال البيانات واستلامها في الوقت نفسه.
تجميع البيانات
عند استخدام حزمة تطوير البرامج (SDK) الخاصة بخدمة "المشاركة عن قرب" في "خدمات Google Play"، يتم جمع إحصاءات الاستخدام بهدف تحسين التجربة.
- مقاييس الأداء: يتم جمع بيانات حول وقت استجابة عملية الرصد والاتصال، والموثوقية، ومعدل نقل البيانات عند البحث عن الأجهزة والاتصال بها باستخدام حزمة تطوير البرامج (SDK) الخاصة بخدمة "الأجهزة المجاورة".
- معلومات الجهاز: يتم جمع طراز الجهاز والبلد وإصدار التصميم واسم حزمة التطبيق وربطها بمقاييس الأداء لتحديد شرائح خاصة بمنطقة معيّنة وبجهاز معيّن.
يمكن للمستخدمين النهائيين السماح بعملية الجمع هذه أو رفضها من خلال الانتقال إلى الإعدادات > Google > الاستخدام وبيانات التشخيص.
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-08-13 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-08-13 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eNearby Connections is a peer-to-peer networking API enabling apps to discover, connect, and exchange data with nearby devices in real-time, even without internet access.\u003c/p\u003e\n"],["\u003cp\u003eIt leverages Bluetooth, BLE, and Wi-Fi for high-bandwidth, low-latency, and encrypted communication, abstracting away the complexities of these technologies.\u003c/p\u003e\n"],["\u003cp\u003eThe API facilitates advertising, discovery, and connection establishment between devices, followed by data exchange using bytes, files, or streams.\u003c/p\u003e\n"],["\u003cp\u003eUsage analytics, including performance metrics and device information, are collected to enhance the API's performance but can be controlled by users in their device settings.\u003c/p\u003e\n"]]],[],null,["# Overview\n\nNearby Connections is a peer-to-peer networking API that allows apps to easily\ndiscover, connect to, and exchange data with nearby devices in real-time,\nregardless of network connectivity.\n\nSome example use cases:\n\n- **Collaborative whiteboard:** Jot ideas down with nearby participants on a shared virtual whiteboard.\n- **Local multiplayer gaming:** Set up a multiplayer game and invite other users nearby to join.\n- **Multi-screen gaming:** Use a phone or tablet as a game controller to play games displayed on a nearby large-screen Android device, such as Android TV.\n- **Offline file transfers:** Share photos, videos, or any other type of data quickly and without requiring a network connection.\n\nIntroduction\n------------\n\nNearby Connections enables advertising, discovery, and connections between\nnearby devices in a fully-offline peer-to-peer manner. Connections between\ndevices are high-bandwidth, low-latency, and fully encrypted to enable fast,\nsecure data transfers.\n\nA primary goal of this API is to provide a platform that is simple, reliable,\nand performant. Under the hood, the API uses a combination of Bluetooth, BLE,\nand Wi-Fi technologies, leveraging the strengths of each while circumventing\ntheir respective weaknesses. This effectively abstracts the vagaries of\nBluetooth and Wi-Fi across a range of platforms and OS versions, allowing\ndevelopers to focus on the features that matter to their users.\n\nAPI overview\n------------\n\nUsage of the API falls into two phases: pre-connection, and post-connection.\n\nIn the pre-connection phase, Advertisers advertise themselves, while Discoverers\ndiscover nearby Advertisers and send connection requests. A connection request\nfrom a Discoverer to an Advertiser initiates a symmetric authentication flow\nthat results in both sides independently accepting (or rejecting) the connection\nrequest.\n\nAfter a connection request is accepted by both sides, the connection is\nconsidered to be established and the devices enter the post-connection phase,\nduring which both sides can exchange data.\n\n### Advertising and discovery\n\nAdvertisers will become visible to other discovers and discoverers will be\nnotified when a new advertiser is found or has been lost.\n\n### Establishing connections\n\nWhen a discoverer wishes to connect to a nearby advertiser, the discoverer can\nrequest a connection.\n\nBoth sides will be notified of the connection initiation process and both will\nhave the opportunity to accept or reject the connection.\n\nOnce both sides have responded, each will be notified of the result. If both\nsides accepted the connection, the connection is considered established, and\ndata transference can then begin.\n\n### Exchanging data\n\nAfter a connection is established, further API usage is symmetrical, so there's\nno longer a distinction between Advertiser and Discoverer.\n\nBoth sides can now exchange data. There are 3 types of supported Payloads:\n\n- **Bytes:** Byte arrays limited to 32k; these are good for sending things such as metadata or control messages.\n- **File:** Files of any size; these are transferred from the app to the network interface with minimal copying across process boundaries.\n- **Stream:** A stream of data that is generated on the fly, as in the case of recorded audio/video, with no final size known beforehand.\n\nReceivers will be notified of new incoming data and any progress updates,\ncancellations or failures.\n\nThe connections established are full-duplex, which means that advertisers and\ndiscoverers can simultaneously send and receive data.\n\n### Data Collection\n\nWhen using the Google Play services Nearby SDK, usage analytics are collected to\nimprove the experience.\n\n- **Performance metrics:** Discovery and connection latency, reliability and throughput are collected when scanning for and connecting to devices using the Nearby SDK.\n- **Device information:** Device model, country, build version and the application package name are collected and associated with the performance metrics to identify regional and device-specific slices.\n\nEnd users can allow or deny this collection by navigating to Settings \\\u003e Google \\\u003e\nUsage \\& diagnostics."]]