1page.title=USB Host and Accessory
2@jd:body
3
4  <div id="qv-wrapper">
5    <div id="qv">
6      <h2>Topics</h2>
7
8      <ol>
9        <li><a href="{@docRoot}guide/topics/connectivity/usb/accessory.html">USB Accessory</a></li>
10
11        <li><a href="{@docRoot}guide/topics/connectivity/usb/host.html">USB Host</a></li>
12      </ol>
13    </div>
14  </div>
15
16  <p>Android supports a variety of USB peripherals and Android USB accessories (hardware that
17  implements the Android accessory protocol) through two modes: USB accessory and USB host. In USB
18  accessory mode, the external USB hardware act as the USB hosts. Examples of accessories might
19  include robotics controllers; docking stations; diagnostic and musical equipment; kiosks; card
20  readers; and much more. This gives Android-powered devices that do not have host capabilities the
21  ability to interact with USB hardware. Android USB accessories must be designed to work with
22  Android-powered devices and must adhere to the <a href=
23  "http://accessories.android.com/demokit">Android accessory communication protocol</a>. In USB
24  host mode, the Android-powered device acts as the host. Examples of devices include digital
25  cameras, keyboards, mice, and game controllers. USB devices that are designed for a wide range of
26  applications and environments can still interact with Android applications that can correctly
27  communicate with the device.</p>
28
29  <p>Figure 1 shows the differences between the two modes. When the Android-powered device is in
30  host mode, it acts as the USB host and powers the bus. When the Android-powered device is in USB
31  accessory mode, the connected USB hardware (an Android USB accessory in this case) acts as the
32  host and powers the bus.</p><img src="{@docRoot}images/usb-host-accessory.png" alt="">
33
34  <p class="img-caption"><strong>Figure 1.</strong> USB Host and Accessory Modes</p>
35
36  <p>USB accessory and host modes are directly supported in Android 3.1 (API level 12) or newer
37  platforms. USB accessory mode is also backported to Android 2.3.4 (API level 10) as an add-on
38  library to support a broader range of devices. Device manufacturers can choose whether or not to
39  include the add-on library on the device's system image.</p>
40
41  <p class="note"><strong>Note:</strong> Support for USB host and accessory modes are ultimately
42  dependant on the device's hardware, regardless of platform level. You can filter for devices that
43  support USB host and accessory through a <a href=
44  "{@docRoot}guide/topics/manifest/uses-feature-element.html">&lt;uses-feature&gt;</a> element. See
45  the USB <a href="{@docRoot}guide/topics/connectivity/usb/accessory.html">accessory</a> and <a href=
46  "{@docRoot}guide/topics/connectivity/usb/host.html">host</a> documentation for more details.</p>
47
48  <h2>Debugging considerations</h2>
49
50  <p>When debugging applications that use USB accessory or host features, you most likely will have
51  USB hardware connected to your Android-powered device. This will prevent you from having an
52  <code>adb</code> connection to the Android-powered device via USB. You can still access
53  <code>adb</code> over a network connection. To enable <code>adb</code> over a network
54  connection:</p>
55
56  <ol>
57    <li>Connect the Android-powered device via USB to your computer.</li>
58
59    <li>From your SDK <code>platform-tools/</code> directory, enter <code>adb tcpip 5555</code> at
60    the command prompt.</li>
61
62    <li>Enter <code>adb connect &lt;device-ip-address&gt;:5555</code> You should now be connected
63    to the Android-powered device and can issue the usual <code>adb</code> commands like <code>adb
64    logcat</code>.</li>
65
66    <li>To set your device to listen on USB, enter <code>adb usb</code>.</li>
67  </ol>
68