Android to PC USB Read/Write

后端 未结 1 1558
日久生厌
日久生厌 2021-02-06 10:13

I have a program on PC taking in string input from USB ( old program) I have a Android (4.X) tablet which needs to provide string input on USB to the program running on PC. Whe

相关标签:
1条回答
  • 2021-02-06 10:45

    I'm not sure I exactly follow what you're doing here, but if I understand you correctly - it just won't work this way. The UsbManager.getDeviceList() is meant to be used with Android devices with USB host port, to which some USB devices are connected. But, as far as I understand, you connect Android tablet acting as a device to your PC acting as a host (I guess so, cause you wrote about driver installation).

    If you want to communicate between Android USB device and some USB host (e.g. because your Android device has no USB host capabilities), you need to use accessory mode (I suggest you start with this Android Developers Blog post). But this mode requires special support on the USB host side (it must talk to the device with Android Open Accessory Protocol). Note, that getDeviceList() makes no sense in Accessory mode - first of all, connected accessory is a USB host, not a USB device, and there can be only one USB host on a USB bus.

    If you want to communicate with PC using Accessory mode, you may want to try this AOAP implementation for PC. If all you need is to talk to Android device for some debugging needs, you may want to use ADB port forwarding and TCP connection instead.

    0 讨论(0)
提交回复
热议问题