1page.title=Custom Accessories
2@jd:body
3
4<!--
5    Copyright 2014 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, lighting control or
28anything else you can imagine. Accessories for Android all have one thing in common; they all
29connect to an Android device in some way. When starting out to build an accessory, you should
30decide how your accessory will connect to Android devices. This page gives you quick overview of
31your options for connecting your Android accessory and resources to help you get started.</p>
32<h2 id="connecting-over-usb">Connecting over USB</h2>
33<p>An accessory that connects to an Android device through a USB cable must support the Android
34Open Accessory (AOA) protocol, which specifies how an accessory can establish communication with
35an Android device over a USB cable. Due to the low power output of Android devices, the AOA
36protocol requires the accessory act as a USB host, which means that the connecting accessory must
37power the bus.</p>
38<p>The AOA protocol has two versions which support different types of communication. Version
391.0 supports a generic accessory communication and adb debugging. This version of the protocol is
40supported by the platform in Android 3.1 (API Level 12) and higher, and supported through an
41<a href="https://developers.google.com/android/add-ons/google-apis/">Add-On Library</a> in Android
422.3.4 (API Level 10) and higher. Version 2.0 of the protocol is available in Android 4.1 (API Level
4316) and adds audio streaming and human interface device (HID) capabilities.</p>
44<p>If you use the general accessory protocol to communicate with your accessory (rather than the
45adb or audio protocol), you must provide an Android application that can detect the connection of
46your USB accessory and establish communication.</p>
47<h3 id="next-steps">Next steps</h3>
48<p>To get started on building an Android accessory that uses a USB connection:</p>
49<ul>
50<li>Select a hardware platform or build a hardware device that can support USB host mode.</li>
51<li>Review the <a href="{@docRoot}accessories/index.html">AOA protocol</a> specifications to understand
52  how to implement this protocol on your accessory hardware. Implementing the
53  <a href="{@docRoot}accessories/aoa2.html">AOA 2.0 protocol</a> is recommended for all new Android USB
54  accessories.</li>
55<li>Review the ADK 2012 <a href="http://developer.android.com/tools/adk/adk2.html#src-download">firmware source code</a>
56  (<code>&lt;adk-src&gt;/adk2012/board/library/ADK2/</code>), which demonstrates an implementation of an accessory
57  using a USB connection for general data communications and audio streaming.</li>
58<li>If you are planning to build an Android application that communicates with your accessory
59  via USB, review the ADK 2012 Android
60  <a href="http://developer.android.com/tools/adk/adk2.html#src-download">application source code</a>
61  (<code>&lt;adk-src&gt;/adk2012/app/</code>).</li>
62</ul>
63<h2 id="connecting-over-bluetooth">Connecting over Bluetooth</h2>
64<p>An accessory that connects with Android devices over a Bluetooth connection can use the
65various connection profiles supported by Android, including the Simple Serial Protocol (SSP) and
66Advanced Audio Distribution Profile (A2DP) profile. An accessory that uses Bluetooth to connect to
67Android devices must support Bluetooth communications and at least one of the supported connection
68profiles.</p>
69<p>Users must enable Bluetooth on their Android device and pair with your accessory in order to
70use it. You can also provide a secondary Android application that handles any specialized
71communication, such as data input or control outputs, to interface with your accessory.</p>
72<h3 id="next-steps_1">Next steps</h3>
73<p>To get started on building an Android accessory that uses a Bluetooth connection:</p>
74<ul>
75<li>Select a hardware platform or build an hardware device that can support Bluetooth
76  communications and an Android supported connection profile, such as SSP or A2DP.</li>
77<li>Review the ADK 2012 <a href="http://developer.android.com/tools/adk/adk2.html#src-download">firmware source code</a>
78  (<code>&lt;adk-src&gt;/adk2012/board/library/ADK2/</code>), which includes an example implementation
79  of general data communications and audio streaming using a Bluetooth connection.</li>
80<li>If you are planning to build an Android application that communicates with your accessory
81  via Bluetooth, review the ADK 2012 Android
82  <a href="http://developer.android.com/tools/adk/adk2.html#src-download">application source code</a>
83  (<code>&lt;adk-src&gt;/adk2012/app/</code>).</li>
84</ul>
85<p><strong>Note:</strong> The ADK 2012 source code includes an open source Bluetooth stack which
86is built for the Texas Instruments CC2564 chip, but can work with any Bluetooth chip that
87supports a standard Host/Controller Interface (HCI).</p>
88
89<h2 id="audio-over-usb">Connecting audio over USB</h2>
90<p>An accessory that connects with Android over USB connection may use the Android Open
91Accessory (AOA) protocol version 2.0. This version of the AOA protocol is supported on Android 4.1
92(API Level 16) and higher. Once an Android device connects to an accessory that supports this
93protocol, the Android system treats it as a standard audio output device and routes all audio to
94that accessory. No secondary software application is required on the Android device.</p>
95<p><strong>Note:</strong> Due to the low power output of Android devices, the Android Open Accessory
96Protocol requires that accessories act as a USB host, which means that the connecting accessory
97must power the bus.</p>
98<h3 id="next-steps">Next steps</h3>
99<p>To get started on building an audio accessory that uses a USB connection:</p>
100<ul>
101<li>Select a hardware platform or build a hardware device that can support USB host mode.</li>
102<li>Review the <a href="{@docRoot}accessories/aoa2.html">AOA 2.0 protocol</a> specification to understand
103  how to implement this protocol on your accessory hardware.</li>
104<li>Review the ADK 2012 <a href="http://developer.android.com/tools/adk/adk2.html#src-download">firmware source code</a>
105  (<code>&lt;adk-src&gt;/adk2012/board/library/ADK2/</code>), which includes an example implementation
106  of an audio playback accessory using a USB connection.</li>
107</ul>
108<p><strong>Note:</strong> The AOA 2.0 protocol also supports the
109<a href="{@docRoot}accessories/aoa2.html#hid-support">human interface device</a> (HID) protocol through a USB
110connection, enabling accessories such as audio docks to provide hardware play back controls such
111as pause, fast-forward or volume buttons.</p>
112