134 lines
6.3 KiB
HTML
134 lines
6.3 KiB
HTML
<html devsite>
|
|
<head>
|
|
<title>Custom Accessories</title>
|
|
<meta name="project_path" value="/_project.yaml" />
|
|
<meta name="book_path" value="/_book.yaml" />
|
|
</head>
|
|
<body>
|
|
<!--
|
|
Copyright 2017 The Android Open Source Project
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
-->
|
|
|
|
|
|
|
|
<p>An accessory for Android can be anything: keyboard, thermometer, robot,
|
|
lighting control, or anything else you can imagine. All Android accessories
|
|
connect to an Android device in some way, so when building an accessory you must
|
|
consider the type of connections your accessory will use. This page provides a
|
|
quick overview of your options for connecting your Android accessory and
|
|
a list of resources to help you get started.</p>
|
|
|
|
<h2 id="connecting-over-usb">Connecting over USB</h2>
|
|
<p>An accessory that connects to an Android device through a USB cable must
|
|
support the Android Open Accessory (AOA) protocol, which specifies how an
|
|
accessory can establish communication with an Android device via USB.
|
|
Due to the low power output of Android devices, AOA requires the accessory to
|
|
act as a USB host, meaning the connecting accessory must power the bus.</p>
|
|
|
|
<p>AOA has two versions that support different types of communication:</p>
|
|
<ul>
|
|
<li><strong>AOAv1</strong>. Supports generic accessory communication and adb
|
|
debugging. Available in Android 3.1 (API Level 12) and higher and supported
|
|
through an
|
|
<a href="https://developers.google.com/android/add-ons/google-apis/">Add-On
|
|
Library</a> in Android 2.3.4 (API Level 10) and higher.</li>
|
|
<li><strong>AOAv2</strong>. Supports audio streaming and human interface
|
|
device (HID) capabilities. Available in Android 4.1 (API Level 16).</li>
|
|
</ul>
|
|
|
|
<p>If you use the general accessory protocol to communicate with your accessory
|
|
(rather than the adb or audio protocol), you must provide an Android application
|
|
that can detect the connection of your USB accessory and establish communication.
|
|
</p>
|
|
|
|
<h3 id="next-steps_0">Next steps</h3>
|
|
<p>To get started building an Android accessory that uses a USB connection:
|
|
</p>
|
|
<ul>
|
|
<li>Select a hardware platform or build a hardware device that can support USB
|
|
host mode.</li>
|
|
<li>Review <a href="protocol.html">AOA</a> specifications to
|
|
understand how to implement this protocol on your accessory hardware.
|
|
Implementing <a href="aoa2.html">AOAv2</a> is
|
|
recommended for all new Android USB accessories.</li>
|
|
<li>Review the ADK 2012
|
|
<a href="http://developer.android.com/tools/adk/adk2.html#src-download">firmware
|
|
source code</a> (<code><adk-src>/adk2012/board/library/ADK2/</code>),
|
|
which demonstrates an implementation of an accessory using a USB connection for
|
|
general data communications and audio streaming.</li>
|
|
<li>When planning to build an Android application that communicates with your
|
|
accessory via USB, review the ADK 2012 Android
|
|
<a href="http://developer.android.com/tools/adk/adk2.html#src-download">application
|
|
source code</a> (<code><adk-src>/adk2012/app/</code>).</li>
|
|
</ul>
|
|
|
|
<h2 id="connecting-over-bluetooth">Connecting over Bluetooth</h2>
|
|
<p>An accessory that connects with Android devices over a Bluetooth connection
|
|
can use connection profiles supported by Android, including the Simple Serial
|
|
Protocol (SSP) and Advanced Audio Distribution Profile (A2DP) profile. An
|
|
accessory that uses Bluetooth to connect to Android devices must support
|
|
Bluetooth communications and at least one of the supported connection profiles.
|
|
</p>
|
|
<p>Users must enable Bluetooth on their Android device and pair with your
|
|
accessory to use the accessory. You can also provide a secondary Android
|
|
application that handles specialized communication such as data input or control
|
|
outputs to interface with your accessory.</p>
|
|
|
|
<h3 id="next-steps_1">Next steps</h3>
|
|
<p>To get started building an Android accessory that uses a Bluetooth connection:
|
|
</p>
|
|
<ul>
|
|
<li>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.</li>
|
|
<li>Review the ADK 2012
|
|
<a href="http://developer.android.com/tools/adk/adk2.html#src-download">firmware
|
|
source code</a> (<code><adk-src>/adk2012/board/library/ADK2/</code>),
|
|
which includes an example implementation of general data communications and
|
|
audio streaming using a Bluetooth connection.</li>
|
|
<li>When planning to build an Android application that communicates with your
|
|
accessory via Bluetooth, review the ADK 2012 Android
|
|
<a href="http://developer.android.com/tools/adk/adk2.html#src-download">application
|
|
source code</a> (<code><adk-src>/adk2012/app/</code>).</li>
|
|
</ul>
|
|
|
|
<p class="note"><strong>Note:</strong> The ADK 2012 source code includes an open
|
|
source Bluetooth stack built for the Texas Instruments CC2564 chip but is
|
|
designed to work with any Bluetooth chip that supports a standard
|
|
Host/Controller Interface (HCI).</p>
|
|
|
|
<h2 id="audio-over-usb">Connecting audio over USB</h2>
|
|
<p>An accessory that connects with Android over USB can use AOAv2 (supported on
|
|
Android 4.1 (API Level 16) and higher. After an Android device connects to an
|
|
accessory that supports this protocol, the Android system treats it as a
|
|
standard audio output device and routes all audio to that accessory. No
|
|
secondary software application is required on the Android device.</p>
|
|
|
|
<p class="note"><strong>Note:</strong> Due to the low power output of Android
|
|
devices, AOA requires accessories to act as a USB host, meaning the connecting
|
|
accessory must power the bus.</p>
|
|
|
|
<h3 id="next-steps_2">Next steps</h3>
|
|
<p>To get started building an audio accessory that uses a USB connection, see
|
|
<a href="#next-steps_0">next steps for USB connections.</a></p>
|
|
|
|
<p>AOAv2 also supports the
|
|
<a href="aoa2.html#hid-support">human interface device</a>
|
|
(HID) protocol through a USB connection, enabling accessories such as audio
|
|
docks to provide hardware play back controls such as pause, fast-forward or
|
|
volume buttons.</p>
|
|
|
|
</body>
|
|
</html>
|