Home | History | Annotate | Download | only in accessories
      1 <html devsite>
      2   <head>
      3     <title>Custom Accessories</title>
      4     <meta name="project_path" value="/_project.yaml" />
      5     <meta name="book_path" value="/_book.yaml" />
      6   </head>
      7   <body>
      8   <!--
      9       Copyright 2017 The Android Open Source Project
     10 
     11       Licensed under the Apache License, Version 2.0 (the "License");
     12       you may not use this file except in compliance with the License.
     13       You may obtain a copy of the License at
     14 
     15           http://www.apache.org/licenses/LICENSE-2.0
     16 
     17       Unless required by applicable law or agreed to in writing, software
     18       distributed under the License is distributed on an "AS IS" BASIS,
     19       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     20       See the License for the specific language governing permissions and
     21       limitations under the License.
     22   -->
     23 
     24 
     25 
     26 <p>An accessory for Android can be anything: keyboard, thermometer, robot,
     27 lighting control, or anything else you can imagine. All Android accessories
     28 connect to an Android device in some way, so when building an accessory you must
     29 consider the type of connections your accessory will use. This page provides a
     30 quick overview of your options for connecting your Android accessory and
     31 a list of resources to help you get started.</p>
     32 
     33 <h2 id="connecting-over-usb">Connecting over USB</h2>
     34 <p>An accessory that connects to an Android device through a USB cable must
     35 support the Android Open Accessory (AOA) protocol, which specifies how an
     36 accessory can establish communication with an Android device via USB.
     37 Due to the low power output of Android devices, AOA requires the accessory to
     38 act as a USB host, meaning the connecting accessory must power the bus.</p>
     39 
     40 <p>AOA has two versions that support different types of communication:</p>
     41 <ul>
     42 <li><strong>AOAv1</strong>. Supports generic accessory communication and adb
     43 debugging. Available in Android 3.1 (API Level 12) and higher and supported
     44 through an
     45 <a href="https://developers.google.com/android/add-ons/google-apis/">Add-On
     46 Library</a> in Android 2.3.4 (API Level 10) and higher.</li>
     47 <li><strong>AOAv2</strong>. Supports audio streaming and human interface
     48 device (HID) capabilities. Available in Android 4.1 (API Level 16).</li>
     49 </ul>
     50 
     51 <p>If you use the general accessory protocol to communicate with your accessory
     52 (rather than the adb or audio protocol), you must provide an Android application
     53 that can detect the connection of your USB accessory and establish communication.
     54 </p>
     55 
     56 <h3 id="next-steps_0">Next steps</h3>
     57 <p>To get started building an Android accessory that uses a USB connection:
     58 </p>
     59 <ul>
     60 <li>Select a hardware platform or build a hardware device that can support USB
     61 host mode.</li>
     62 <li>Review <a href="protocol.html">AOA</a> specifications to
     63 understand how to implement this protocol on your accessory hardware.
     64 Implementing <a href="aoa2.html">AOAv2</a> is
     65 recommended for all new Android USB accessories.</li>
     66 <li>Review the ADK 2012
     67 <a href="http://developer.android.com/tools/adk/adk2.html#src-download">firmware
     68 source code</a> (<code>&lt;adk-src&gt;/adk2012/board/library/ADK2/</code>),
     69 which demonstrates an implementation of an accessory using a USB connection for
     70 general data communications and audio streaming.</li>
     71 <li>When planning to build an Android application that communicates with your
     72 accessory via USB, review the ADK 2012 Android
     73 <a href="http://developer.android.com/tools/adk/adk2.html#src-download">application
     74 source code</a> (<code>&lt;adk-src&gt;/adk2012/app/</code>).</li>
     75 </ul>
     76 
     77 <h2 id="connecting-over-bluetooth">Connecting over Bluetooth</h2>
     78 <p>An accessory that connects with Android devices over a Bluetooth connection
     79 can use connection profiles supported by Android, including the Simple Serial
     80 Protocol (SSP) and Advanced Audio Distribution Profile (A2DP) profile. An
     81 accessory that uses Bluetooth to connect to Android devices must support
     82 Bluetooth communications and at least one of the supported connection profiles.
     83 </p>
     84 <p>Users must enable Bluetooth on their Android device and pair with your
     85 accessory to use the accessory. You can also provide a secondary Android
     86 application that handles specialized communication such as data input or control
     87 outputs to interface with your accessory.</p>
     88 
     89 <h3 id="next-steps_1">Next steps</h3>
     90 <p>To get started building an Android accessory that uses a Bluetooth connection:
     91 </p>
     92 <ul>
     93 <li>Select a hardware platform or build an hardware device that can support
     94 Bluetooth communications and an Android supported connection profile, such as
     95 SSP or A2DP.</li>
     96 <li>Review the ADK 2012
     97 <a href="http://developer.android.com/tools/adk/adk2.html#src-download">firmware
     98 source code</a> (<code>&lt;adk-src&gt;/adk2012/board/library/ADK2/</code>),
     99 which includes an example implementation of general data communications and
    100 audio streaming using a Bluetooth connection.</li>
    101 <li>When planning to build an Android application that communicates with your
    102 accessory via Bluetooth, review the ADK 2012 Android
    103 <a href="http://developer.android.com/tools/adk/adk2.html#src-download">application
    104 source code</a> (<code>&lt;adk-src&gt;/adk2012/app/</code>).</li>
    105 </ul>
    106 
    107 <p class="note"><strong>Note:</strong> The ADK 2012 source code includes an open
    108 source Bluetooth stack built for the Texas Instruments CC2564 chip but is
    109 designed to work with any Bluetooth chip that supports a standard
    110 Host/Controller Interface (HCI).</p>
    111 
    112 <h2 id="audio-over-usb">Connecting audio over USB</h2>
    113 <p>An accessory that connects with Android over USB can use AOAv2 (supported on
    114 Android 4.1 (API Level 16) and higher. After an Android device connects to an
    115 accessory that supports this protocol, the Android system treats it as a
    116 standard audio output device and routes all audio to that accessory. No
    117 secondary software application is required on the Android device.</p>
    118 
    119 <p class="note"><strong>Note:</strong> Due to the low power output of Android
    120 devices, AOA requires accessories to act as a USB host, meaning the connecting
    121 accessory must power the bus.</p>
    122 
    123 <h3 id="next-steps_2">Next steps</h3>
    124 <p>To get started building an audio accessory that uses a USB connection, see
    125 <a href="#next-steps_0">next steps for USB connections.</a></p>
    126 
    127 <p>AOAv2 also supports the
    128 <a href="aoa2.html#hid-support">human interface device</a>
    129 (HID) protocol through a USB connection, enabling accessories such as audio
    130 docks to provide hardware play back controls such as pause, fast-forward or
    131 volume buttons.</p>
    132 
    133   </body>
    134 </html>
    135