4

I have 2 Android devices, which I would like to connect with a USB OTG cable and have back-and-forth communication between the two devices. From what I understand, one Android device will act as the USB Host (Nexus 7 running 4.4) and the other Android device will act as a USB Accessory (Galaxy Nexus running 4.2.2). I've tried googling around for an answer, but I can only seem to find articles explaining how to connect an Android device to a USB accessory (like a USB mouse or keyboard), not how to treat an Android device as the USB accessory itself.

So, following this page, I have configured an app on the Nexus 7 to be the USB Host. I can find the connected Galaxy Nexus based on its product id & vendor id, form a connection to the Android Open Accessory Protocol and successfully connect over USB. From what I can tell, the Nexus 7 can successfully send bytes to the Galaxy Nexus.

My question is how to access this connection on the Galaxy Nexus side. I have added permissions and the USB filter into the manifest, so the desired app opens on the Galaxy Nexus once the USB connection is established, but I can't figure out how to receive the data coming in from the Nexus 7 or how to send data from the Galaxy Nexus back to the Nexus 7.

Any help would be greatly appreciated! Thanks!

lifeson106
  • 503
  • 4
  • 11
  • 4
    Whoever called this off topic is severely mistaken. This concerns **software development** utilizing the **android APIs**. – Chris Stratton Nov 26 '13 at 19:42
  • There is no generic "USB device" API in Android for operating as a USB slave. Your best best is probably to look at the ADK protocol - have the "host" device play the role of the external embedded USB host (ie, the job normally done by the ADK board, Arduino + USB host shield, or ioio board). Then you can use the ADK APIs on the "slave" device. – Chris Stratton Nov 26 '13 at 19:43

1 Answers1

0

See my SO answer here.

If you want the Galaxy Nexus to act as the USB Accessory, then it must implement the Android Open Accessory protocol. An Android Accessory is a usb host, so technically you would have two hosts (assuming you managed to implement correctly the AOA protocol on the Galaxy Nexus), which is clearly a deviation of the USB spec.

Community
  • 1
  • 1
Luis
  • 3,451
  • 1
  • 27
  • 41