Xamarin Forms Android App Connect/Communicate via USB to PC

CatimusCatimus USMember ✭✭

Hello,
I am working on an Android (Xamarin Forms) application, and have a need to communicate with a Windows PC. This communication NEEDS to happen over USB cable. I googled this problem and found a couple of incredibly similar projects anotherlab's UsbSerialForAndroid, and lusovu's XmarinUsbSerial.

I am using anotherlab's project as a starting point on how to get android -> pc usb comms working, but am running into the problem of never being able to find any devices when the tablet is plugged into the PC. I have tried using a regular USB cable as well as an OTG cable without any luck. I just can't figure out why the device list is empty when using the following lines of code:

    usbManager = GetSystemService(Context.UsbService) as UsbManager;
    IDictionary<string, UsbDevice> devices = usbManager.DeviceList;

I'm thinking it might be a problem with the drivers it's using but I have no clue as to how to get the vendor id or the product id of the usb host controller in my laptop (done a quick search). Could it be something else?

I can connect to an Arduino device using the OTG cable and can get the project working with it, but I need it to work with a PC not an Arduino.

If anyone has any ideas I would be grateful,
Thanks

Best Answer

Answers

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    @Catimus

    I am not sure this applies here, but some Android devices do require you to install their own drivers for USB communications when using the device for debugging for instance. I know with Samsung devices you need to do this. So you might try going to the Android device manufacturer's website and seeing if there are Windows drivers to install.

  • CatimusCatimus USMember ✭✭

    @JGoldberger
    Thank you for your prompt response and your suggestion. I tried downloading the latest Acer drivers which were much older than the ones I already had for Win10, but what the heck they're "official." Running with them now, but still no change in behavior. Still searching for an answer.

  • CatimusCatimus USMember ✭✭

    Thank you for the information. It looks like I going down a path that had a very messy end. I am looking at other methods of transferring the data.

  • MelbourneDeveloperMelbourneDeveloper AUMember ✭✭✭
    edited August 11

    @Catimus if you are still working on this project, I'd like to point you to Device.Net. There is a specific library for Android USB access, but it is more of a framework for cross platform development so that code can be shared on other platforms.

    Here is a forum post about the latest release:
    https://forums.xamarin.com/discussion/165103/usb-net-and-hid-net-version-3-beta#latest

    It would be great if you could share your existing solution to see if it could help to improve Device.Net.

Sign In or Register to comment.