اعتبارًا من 27 آذار (مارس) 2025، ننصحك باستخدام android-latest-release
بدلاً من aosp-main
لإنشاء AOSP والمساهمة فيه. لمزيد من المعلومات، يُرجى الاطّلاع على التغييرات في AOSP.
الملحقات المخصّصة
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يمكن أن يكون الملحق المخصّص لأجهزة Android أيًّا مما يلي: لوحة مفاتيح أو ميزان حرارة أو روبوت أو جهاز التحكّم في الإضاءة أو أيّ شيء آخر تتخيله. تتصل جميع ملحقات Android
بجهاز Android بطريقة أو بأخرى، لذا عند تصميم ملحق، يجب مراعاة نوع عمليات الربط التي سيستخدمها الملحق. تقدّم هذه الصفحة
نظرة عامة سريعة على خيارات ربط ملحق Android
وقائمة بالموارد لمساعدتك في البدء.
الاتصال عبر USB
يجب أن يكون الملحق الذي يتم توصيله بجهاز Android من خلال كابل USB متوافقًا مع بروتوكول Android Open Accessory (AOA) الذي يحدِّد كيفية بدء الملحق للتواصل مع جهاز Android عبر USB.
بسبب انخفاض طاقة أجهزة Android، تتطلّب واجهة AOA أن يعمل الملحق
كمضيف USB، ما يعني أنّ الملحق المتصل يجب أن يمدّ الحافلة بالطاقة.
يتوفّر لبروتوكول AOA إصداران يتيحان أنواعًا مختلفة من الاتصالات:
- AOAv1.
تتيح هذه الميزة التواصل العام مع الملحقات وتصحيح أخطاء adb.
- AOAv2. توفُّر إمكانات
جهاز واجهة المستخدم (HID) تتوفّر هذه الميزة في الإصدار 4.1
(المستوى 16 لواجهة برمجة التطبيقات) من نظام التشغيل Android أو إصدار أحدث.
إذا كنت تستخدم بروتوكول الملحقات العام للتواصل مع الملحق
(بدلاً من بروتوكول adb أو بروتوكول الصوت)، يجب توفير تطبيق Android
يمكنه رصد اتصال الملحق USB وبدء
التواصل معه.
الخطوات التالية
لبدء إنشاء ملحق Android يستخدم اتصالاً عبر USB، اتّبِع الخطوات التالية:
- اختَر نظامًا أساسيًا للأجهزة أو أنشئ جهازًا للأجهزة يمكنه استخدام وضع مضيف USB.
- راجِع مواصفات AOA لفهم كيفية تنفيذ هذا البروتوكول على الأجهزة الملحقة.
- راجِع رمز المصدر
للبرامج الثابتة (
<adk-src>/adk2012/board/library/ADK2/
) في ADK 2012، والذي يوضّح تنفيذ ملحق باستخدام اتصال USB لبث الموسيقى ونقل البيانات بشكل عام.
- عند التخطيط لإنشاء تطبيق Android يتواصل مع الملحق عبر USB، راجِع رمز المصدر لتطبيق Android في حزمة ADK 2012 (
<adk-src>/adk2012/app/
).
الاتصال عبر البلوتوث
يمكن أن يستخدم الملحق الذي يتم توصيله بأجهزة Android عبر اتصال بلوتوثملفّات ربط متوافقة مع Android، بما في ذلك بروتوكول SSP (بروتوكول تسلسلي بسيط) وملف A2DP (ملف توزيع الصوت المتقدّم). يجب أن يتوافق
الملحق الذي يستخدم البلوتوث للاتصال بأجهزة Android مع
اتصالات البلوتوث وأحد الملفات الشخصية للاتصال على الأقل.
لاستخدام الملحق، على المستخدمين تفعيل البلوتوث على أجهزة Android وإقرانه
بالملحق. يمكنك أيضًا توفير تطبيق Android
ثانوي يتعامل مع الاتصالات المتخصصة، مثل إدخال البيانات أو التحكّم في المخرجات
للتفاعل مع الملحق.
الخطوات التالية
لبدء إنشاء ملحق Android يستخدم اتصالاً عبر البلوتوث، اتّبِع الخطوات التالية:
- اختَر منصة أجهزة أو أنشئ جهازًا يمكنه إتاحة اتصالات برمجة التطبيقات Bluetooth وملف اتصال متوافق مع Android، مثل SSP أو A2DP.
- راجِع رمز المصدر
للبرامج الثابتة (
<adk-src>/adk2012/board/library/ADK2/
) في ADK 2012، والذي يتضمّن مثالاً على تنفيذ عمليات نقل البيانات العامة وبث الموسيقى باستخدام اتصال بلوتوث.
- عند التخطيط لإنشاء تطبيق Android يتواصل مع
الملحق عبر البلوتوث، راجِع رمز المصدر لتطبيق Android في حزمة ADK 2012 (
<adk-src>/adk2012/app/
).
ملاحظة: يتضمّن رمز ADK 2012 المصدر بنية بلوتوث مفتوحة
المصدر تم إنشاؤها لشريحة Texas Instruments CC2564، ولكن تم
تصميمها للعمل مع أي شريحة بلوتوث متوافقة مع واجهة برمجة التطبيقات لجهاز التحكم/المضيف (HCI).
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-27 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Custom accessories\n\nAn accessory for Android can be anything: keyboard, thermometer, robot,\nlighting control, or anything else you can imagine. All Android accessories\nconnect to an Android device in some way, so when building an accessory you must\nconsider the type of connections your accessory will use. This page provides a\nquick overview of your options for connecting your Android accessory and\na list of resources to help you get started.\n\nConnect over USB\n----------------\n\nAn accessory that connects to an Android device through a USB cable must\nsupport the Android Open Accessory (AOA) protocol, which specifies how an\naccessory can establish communication with an Android device via USB.\nDue to the low power output of Android devices, AOA requires the accessory to\nact as a USB host, meaning the connecting accessory must power the bus.\n\nAOA has two versions that support different types of communication:\n\n- **[AOAv1](/docs/core/interaction/accessories/aoa).** Supports generic accessory communication and adb debugging.\n- **[AOAv2](/docs/core/interaction/accessories/aoa2).** Supports human interface device (HID) capabilities. Available in Android 4.1 (API Level 16) or higher.\n\nIf you use the general accessory protocol to communicate with your accessory\n(rather than the adb or audio protocol), you must provide an Android\napp that can detect the connection of your USB accessory and establish\ncommunication.\n\n### Next steps\n\nTo get started building an Android accessory that uses a USB connection:\n\n- Select a hardware platform or build a hardware device that can support USB host mode.\n- Review [AOA](/docs/core/interaction/accessories/protocol) specifications to understand how to implement this protocol on your accessory hardware.\n- Review the ADK 2012 [firmware\n source code](http://developer.android.com/tools/adk/adk2.html#src-download) (`\u003cadk-src\u003e/adk2012/board/library/ADK2/`), which demonstrates an implementation of an accessory using a USB connection for general data communications and audio streaming.\n- When planning to build an Android app that communicates with your accessory via USB, review the ADK 2012 Android [app\n source code](http://developer.android.com/tools/adk/adk2.html#src-download) (`\u003cadk-src\u003e/adk2012/app/`).\n\nConnect over Bluetooth\n----------------------\n\nAn accessory that connects with Android devices over a Bluetooth connection\ncan use connection profiles supported by Android, including the Simple Serial\nProtocol (SSP) and Advanced Audio Distribution Profile (A2DP) profile. An\naccessory that uses Bluetooth to connect to Android devices must support\nBluetooth communications and at least one of the supported connection profiles.\n\nUsers must enable Bluetooth on their Android device and pair with your\naccessory to use the accessory. You can also provide a secondary Android\napp that handles specialized communication such as data input or control\noutputs to interface with your accessory.\n\n### Next steps\n\nTo get started building an Android accessory that uses a Bluetooth connection:\n\n- Select a hardware platform or build an hardware device that can support Bluetooth communications and an Android supported connection profile, such as SSP or A2DP.\n- Review the ADK 2012 [firmware\n source code](http://developer.android.com/tools/adk/adk2.html#src-download) (`\u003cadk-src\u003e/adk2012/board/library/ADK2/`), which includes an example implementation of general data communications and audio streaming using a Bluetooth connection.\n- When planning to build an Android app that communicates with your accessory via Bluetooth, review the ADK 2012 Android [app\n source code](http://developer.android.com/tools/adk/adk2.html#src-download) (`\u003cadk-src\u003e/adk2012/app/`).\n\n**Note:** The ADK 2012 source code includes an open\nsource Bluetooth stack built for the Texas Instruments CC2564 chip but is\ndesigned to work with any Bluetooth chip that supports a standard\nHost/Controller Interface (HCI)."]]