summaryrefslogtreecommitdiffstats
path: root/docs/html/guide/topics/usb/index.jd
blob: 6dc8ec5d6e363c203d9bf17ce2eb1d2e8fb31b97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
page.title=USB Host and Accessory
@jd:body

  <div id="qv-wrapper">
    <div id="qv">
      <h2>Topics</h2>

      <ol>
        <li><a href="{@docRoot}guide/topics/usb/accessory.html">USB Accessory</a></li>

        <li><a href="{@docRoot}guide/topics/usb/host.html">USB Host</a></li>
      </ol>
    </div>
  </div>

  <p>Android supports a variety of USB peripherals and Android USB accessories (hardware that
  implements the Android accessory protocol) through two modes: USB accessory and USB host. In USB
  accessory mode, the external USB hardware act as the USB hosts. Examples of accessories might
  include robotics controllers; docking stations; diagnostic and musical equipment; kiosks; card
  readers; and much more. This gives Android-powered devices that do not have host capabilities the
  ability to interact with USB hardware. Android USB accessories must be designed to work with
  Android-powered devices and must adhere to the <a href=
  "http://accessories.android.com/demokit">Android accessory communication protocol</a>. In USB
  host mode, the Android-powered device acts as the host. Examples of devices include digital
  cameras, keyboards, mice, and game controllers. USB devices that are designed for a wide range of
  applications and environments can still interact with Android applications that can correctly
  communicate with the device.</p>

  <p>Figure 1 shows the differences between the two modes. When the Android-powered device is in
  host mode, it acts as the USB host and powers the bus. When the Android-powered device is in USB
  accessory mode, the connected USB hardware (an Android USB accessory in this case) acts as the
  host and powers the bus.</p><img src="{@docRoot}images/usb-host-accessory.png" alt="">

  <p class="img-caption"><strong>Figure 1.</strong> USB Host and Accessory Modes</p>

  <p>USB accessory and host modes are directly supported in Android 3.1 (API level 12) or newer
  platforms. USB accessory mode is also backported to Android 2.3.4 (API level 10) as an add-on
  library to support a broader range of devices. Device manufacturers can choose whether or not to
  include the add-on library on the device's system image.</p>

  <p class="note"><strong>Note:</strong> Support for USB host and accessory modes are ultimately
  dependant on the device's hardware, regardless of platform level. You can filter for devices that
  support USB host and accessory through a <a href=
  "{@docRoot}guide/topics/manifest/uses-feature-element.html">&lt;uses-feature&gt;</a> element. See
  the USB <a href="{@docRoot}guide/topics/USB/accessory.html">accessory</a> and <a href=
  "{@docRoot}guide/topics/USB/host.html">host</a> documentation for more details.</p>

  <h2>Debugging considerations</h2>

  <p>When debugging applications that use USB accessory or host features, you most likely will have
  USB hardware connected to your Android-powered device. This will prevent you from having an
  <code>adb</code> connection to the Android-powered device via USB. You can still access
  <code>adb</code> over a network connection. To enable <code>adb</code> over a network
  connection:</p>

  <ol>
    <li>Connect the Android-powered device via USB to your computer.</li>

    <li>From your SDK <code>platform-tools/</code> directory, enter <code>adb tcpip 5555</code> at
    the command prompt.</li>

    <li>Enter <code>adb connect &lt;device-ip-address&gt;:5555</code> You should now be connected
    to the Android-powered device and can issue the usual <code>adb</code> commands like <code>adb
    logcat</code>.</li>

    <li>To set your device to listen on USB, enter <code>adb usb</code>.</li>
  </ol>