با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
پیشنمایش توسعهدهنده SDK دستگاه Cross از طریق یک پروژه منبع باز توزیع میشود. این پیشنمایش برای جامعه توسعهدهندگان برای نمونهسازی و اعتبارسنجی تجربیات چند دستگاهی در دسترس است، اما برای استفاده در برنامههای تولید در نظر گرفته نشده است.
در طول پیشنمایش برنامهنویس، API در معرض تغییر است، بنابراین یادداشتهای انتشار را مرتباً بررسی کنید تا مطمئن شوید که از آخرین نسخه SDK دستگاه Cross استفاده میکنید.
یکی از مزایای استفاده از Cross device SDK این است که اکتشافات محلی مانند BLUETOOTH_CONNECT ، BLUETOOTH_SCAN و ACCESS_FINE_LOCATION را انتزاعی می کند.
APIهای متقابل دستگاه
هدف هر API در Cross device SDK حل یک کار مشترک در چارچوب چند دستگاهی است:
کشف دستگاه: به راحتی دستگاه های نزدیک را پیدا کنید، ارتباط همتا به همتا را مجاز کنید و برنامه مورد نظر را در دستگاه دریافت کننده شروع کنید.
ارتباطات ایمن: اشتراک گذاری داده های رمزگذاری شده، کم تأخیر و دو جهته را بین دستگاه های مجاز فعال کنید.
جلسات چند دستگاهی: انتقال یا گسترش تجربه کاربری یک برنامه در سراسر دستگاه ها.
این APIها از طریق کلاسهای Discovery و Sessions در دسترس هستند:
میتوانید در بخشهای زیر درباره کاربردهای خاص این APIها بیشتر بدانید یا به مخزن نمونه برنامه ما مراجعه کنید.
نمونه برنامه های کاربردی
ما تعدادی برنامه برای نمایش SDK دستگاه Cross در عمل آماده کرده ایم. این نمونه برنامهها حول یک بازی ساده راک، کاغذ، قیچی بهعنوان روشی بصری و تعاملی برای آشنایی با APIها ساخته شدهاند. ما شما را تشویق می کنیم که کد نمونه را بررسی و اصلاح کنید تا نحوه استفاده از آن را ببینید:
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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-07-29 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Get started\n\nThe Cross device SDK Developer Preview is distributed through an [open-source\nproject](https://github.com/google/cross-device-sdk). This preview is available for the developer community to prototype and\nvalidate multidevice experiences but is not intended for use in production\napplications.\n| **Note:** Quick Share must be turned on to use the Cross device SDK. See [Share files and links with nearby devices](https://support.google.com/android/answer/9286773) to learn more.\n\nSet up Google Play Services\n---------------------------\n\nBefore you start coding,\n[ensure Google Play Services is installed](https://developers.google.com/android/guides/setup#check-whether-installed).\nThe Cross device SDK is in Developer Preview and is available only through the\nGoogle Play Services Beta Program. See\n[this guide](https://developers.google.com/android/guides/beta-program) on how\nto enroll in the Beta Program.\n\nOnce you enroll in the Beta Program and install the appropriate beta version of\nGoogle Play Services, you're ready to begin developing multidevice experiences\nwith the Cross device SDK.\n\nDependencies and permissions\n----------------------------\n\nFirst, open your app module `build.gradle` file and add a dependency on the\nCross device SDK as follows: \n\n dependencies {\n implementation 'com.google.ambient.crossdevice:crossdevice:0.1.0-preview01'\n }\n\nDuring Developer Preview, the API is subject to change, so check release notes\nregularly to ensure you're using the latest version of the Cross device SDK.\n\nOne of the benefits of using the Cross device SDK is that it abstracts away\nlocal discovery, such as `BLUETOOTH_CONNECT`, `BLUETOOTH_SCAN`, and\n`ACCESS_FINE_LOCATION`.\n| **Note:** You still have to declare and request runtime permissions required by your app features and API outside of the Cross device SDK. For instance, you might need `BLUETOOTH_SCAN` permission to perform a Bluetooth scan outside of the Cross device SDK.\n\nCross device APIs\n-----------------\n\nEach API in the Cross device SDK is aimed at solving a common task within a\nmultidevice framework:\n\n- Device discovery: Easily find nearby devices, authorize peer-to-peer communication, and start the target application on the receiving device.\n- Secure communications: Enable encrypted, low-latency, bi-directional data sharing between authorized devices.\n- Multidevice sessions: Transfer or extend an application's user-experience across devices.\n\nThese APIs are available through the `Discovery` and `Sessions` classes: \n\n### Kotlin\n\n```kotlin\nval discovery = Discovery.create(context)\nval sessions = Sessions.create(context)\n```\n\n### Java\n\n```java\nDiscovery discovery = Discovery.create(context);\nSessions sessions = Sessions.create(context);\n```\n\nYou can learn more about the specific uses of these APIs in the following\nsections, or refer to our\n[sample app repository](https://github.com/android/connectivity-samples).\n| **Note:** The Cross device SDK is asynchronous by design. If you are unfamiliar with asynchronous operations, we encourage you to learn about [`Coroutines`](https://kotlinlang.org/docs/coroutines-guide.html) for Kotlin or [`ListenableFuture`](https://developer.android.com/guide/background/listenablefuture) for Java.\n\nSample Applications\n-------------------\n\nWe've prepared a number of apps to demonstrate the Cross device SDK in action.\nThese sample apps are built around a simple Rock, Paper, Scissors game as an\nintuitive and interactive way to familiarize yourself with the APIs. We\nencourage you to explore and modify the sample code to see how to use:\n\n- Device Discovery\n- Secure Connections\n- Sessions Transfer\n- Shared Sessions\n\nCheck out\n[Cross-device Rock, Paper, Scissors on Github](https://github.com/android/connectivity-samples/tree/main/CrossDeviceRockPaperScissors)."]]