USB ホストとアクセサリの概要
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Android は、USB アクセサリと USB ホストの 2 つのモードで、さまざまな USB 周辺機器と Android USB アクセサリ(Android アクセサリ プロトコルを実装しているハードウェア)をサポートしています。USB アクセサリ モードでは、外部 USB ハードウェアが USB ホストとして機能します。アクセサリの例:
- ロボット工学 コントローラ
- ドッキング ステーション
- 診断、音楽機器
- キオスク
- カードリーダー
その他多数。これにより、ホスト機能を持たない Android 搭載デバイスで USB ハードウェアを操作できます。Android USB アクセサリは、Android 搭載デバイスと連携するように設計され、Android アクセサリの通信プロトコルに準拠している必要があります。USB ホストモードでは、Android 搭載デバイスがホストとして機能します。デバイスの例としては、デジタルカメラ、キーボード、マウス、ゲーム コントローラなどがあります。さまざまなアプリや環境向けに設計された USB デバイスでも、デバイスと正しく通信できる Android アプリとやり取りできます。
図 1 は 2 つのモードの違いを示しています。Android 搭載デバイスがホストモードのときは、USB ホストとして機能し、バスに電力を供給します。Android 搭載デバイスが USB アクセサリ モードの場合、接続された USB ハードウェア(この場合は Android USB アクセサリ)がホストとして機能し、バスに電力を供給します。

図 1. USB ホストモードとアクセサリ モード
USB アクセサリとホストモードは、Android 3.1(API レベル 12)以降のプラットフォームで直接サポートされます。また、USB アクセサリ モードは、アドオン ライブラリとして Android 2.3.4(API レベル 10)にバックポートされており、幅広いデバイスをサポートしています。デバイス メーカーは、デバイスのシステム イメージにアドオン ライブラリを含めるかどうかを選択できます。
注: USB ホストモードとアクセサリ モードのサポートは、プラットフォーム レベルに関係なく、最終的にはデバイスのハードウェアに依存します。<uses-feature>
要素を使用すると、USB ホストとアクセサリをサポートするデバイスをフィルタできます。詳しくは、USB アクセサリとホストのドキュメントをご覧ください。
デバッグに関する考慮事項
USB アクセサリまたはホスト機能を使用するアプリをデバッグする場合、USB ハードウェアを Android 搭載デバイスに接続していることがよくあります。これにより、USB を使用して Android 搭載デバイスに adb
接続できなくなります。adb
にはネットワーク接続を介して引き続きアクセスできます。ネットワーク接続経由で adb
を有効にするには:
- USB を使用して Android 搭載デバイスをパソコンに接続します。
- SDK の
platform-tools/
ディレクトリで、コマンド プロンプトに「adb tcpip 5555
」と入力します。
- 「
adb connect <device-ip-address>:5555
」と入力します。Android 搭載デバイスに接続され、adb logcat
などの通常の adb
コマンドを発行できます。
- USB をリッスンするようにデバイスを設定するには、
adb usb
と入力します。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-26 UTC。
[null,null,["最終更新日 2025-07-26 UTC。"],[],[],null,["# USB host and accessory overview\n\nAndroid supports a variety of USB peripherals and Android USB accessories\n(hardware that implements the Android accessory protocol) through two modes: USB\naccessory and USB host. In USB accessory mode, the external USB hardware acts as\nthe USB host. Examples of accessories might include:\n\n- robotics controllers\n- docking stations\n- diagnostic and musical equipment\n- kiosks\n- card readers\n\nand many more. This gives Android-powered devices that don't have host\ncapabilities the ability to interact with USB hardware. Android\nUSB accessories must be\ndesigned to work with Android-powered devices and must adhere to the [Android\naccessory communication protocol](http://accessories.android.com/demokit). In\nUSB host mode, the Android-powered device acts as the host. Examples of devices\ninclude digital cameras, keyboards, mice, and game controllers. USB devices that\nare designed for a wide range of applications and environments can still\ninteract with Android applications that can correctly communicate with the\ndevice.\n\nFigure 1 shows the differences between the two modes. When the Android-powered\ndevice is in host mode, it acts as the USB host and powers the bus. When the\nAndroid-powered device is in USB accessory mode, the connected USB hardware (an\nAndroid USB accessory in this case) acts as the host and powers the bus.\n\n**Figure 1.** USB Host and Accessory Modes\n\nUSB accessory and host modes are directly supported in Android 3.1 (API level\n12) or newer platforms. USB accessory mode is also backported to Android 2.3.4\n(API level 10) as an add-on library to support a broader range of devices.\nDevice manufacturers can choose whether or not to include the add-on library on\nthe device\\\\'s system image.\n\n**Note:** Support for USB host and accessory modes are ultimately dependant on\nthe device\\\\'s hardware, regardless of platform level. You can filter for devices\nthat support USB host and accessory through a\n[`\u003cuses-feature\u003e`](/guide/topics/manifest/uses-feature-element) element.\nSee the USB [accessory](/develop/connectivity/usb/accessory) and\n[host](/develop/connectivity/usb/host) documentation for more details.\n\nDebug considerations\n--------------------\n\nWhen debugging applications that use USB accessory or host features, you most\nlikely have USB hardware connected to your Android-powered device. This\nprevents you from having an `adb` connection to the Android-powered device\nusing USB. You can still access `adb` over a network connection. To enable `adb`\nover a network connection:\n\n1. Connect the Android-powered device using USB to your computer.\n2. From your SDK `platform-tools/` directory, enter `adb tcpip 5555` at the command prompt.\n3. Enter `adb connect \u003cdevice-ip-address\u003e:5555` You should now be connected to the Android-powered device and can issue the usual `adb` commands like `adb logcat`.\n4. To set your device to listen on USB, enter `adb usb`."]]