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