USB Host and Accessory

Topics

  1. USB Accessory
  2. USB Host

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 Android accessory communication protocol. 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.

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.

Android USB Host and Accessory_第1张图片

Figure 1. USB Host and Accessory Modes

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.

Note: 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 <uses-feature> element. See the USB accessory and host documentation for more details.

Debugging considerations

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 adb connection to the Android-powered device via USB. You can still access adb over a network connection. To enable adb over a network connection:

  1. Connect the Android-powered device via USB to your computer.
  2. From your SDK platform-tools/ directory, enter adb tcpip 5555 at the command prompt.
  3. Enter adb connect <device-ip-address>:5555 You should now be connected to the Android-powered device and can issue the usual adb commands like adb logcat.
  4. To set your device to listen on USB, enter adb usb.

更多相关文章

  1. android adapter 异步加载图片
  2. android点击实现图片放大缩小
  3. android去掉标题栏、信息栏、获取屏幕分辨率、图片全屏
  4. android自定义带图片的title
  5. Android Studio Gradle多渠道打包(动态设定App名称,应用图标,背景
  6. Android图片剪裁-调用系统实现,完美适配魅族等机型
  7. Android 添加图片水印(图片+文字)
  8. android上传图片到服务器,求服务器那边和android的Activity的完整
  9. Android中上传图片到服务端C#接收图

随机推荐

  1. Android(安卓)NDK开发技巧二
  2. Android开发的前景分析――之你为何看好A
  3. Android开发实例源代码批量下载
  4. Android的建议
  5. Android的init过程详解(一)
  6. 详解 Android(安卓)的 Activity 组件
  7. Android(安卓)驱动开发---Android(安卓)L
  8. Android(安卓)WebKit实例简单实现
  9. Android(安卓)MVC
  10. Android(安卓)Instrumentation Testing