Click here to Skip to main content
15,921,959 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All;

I got an HID USB device , I build for it a windows application using c# then it was connected successfully after adding its VendorID and ProductID, the Device of Class=03,subClass=01,Portocol=0;

after I try to build an Application on Android and try connecting it , it was detected on the Mobile but in my application it was not detected, But I have tried other device of Class=02 and Class=01 they was detected ,

So I searched and I have found that Class03 was used as Android USB constant so it will be blacklisted , so I asked the manufacture to change the Firmware to class=01 and after they have done it , also still not working .

there is a sample of my application code :

Java
if (myUsbManager == null)
              return;

          HashMap<String, UsbDevice> deviceList = myUsbManager.getDeviceList();
          if (!deviceList.isEmpty()) { // deviceList
              StringBuffer sb = new StringBuffer();
              for (UsbDevice device : deviceList.values()) {
                  sb.append(device.toString());
                  sb.append("\n");
                  edtText.setText(sb);

                  mLog("DeviceInfo: " + device.getVendorId() + " , "
                          + device.getProductId());

                  if (device.getVendorId() == VendorID
                          && device.getProductId() == ProductID) {
                      myUsbDevice = device;
                      mLog("USB DEVICE SAME VENDOR ID");
                  }
              }
          }


So I was in doubt if my code have an issue or this device in not compatible , but why it was read on the c# application but not on Android application . or is there anymore settings I have to add in my apk

Note that I have tried my apk to connect to Smartcard reader , USB Host , bluetooth devices , and many other devices and all was of class=01 and class=2 and was being read .
Posted

1 solution

C#
if (myUsbManager == null)
                return;

            HashMap<String, UsbDevice> deviceList = myUsbManager.getDeviceList();
            if (!deviceList.isEmpty()) { // deviceList
                StringBuffer sb = new StringBuffer();
                for (UsbDevice device : deviceList.values()) {
                    sb.append(device.toString());
                    sb.append("\n");
                    edtText.setText(sb);

                    mLog("DeviceInfo: " + device.getVendorId() + " , "
                            + device.getProductId());

                    if (device.getVendorId() == VendorID
                            && device.getProductId() == ProductID) {
                        myUsbDevice = device;
                        mLog("USB DEVICE SAME VENDOR ID");
                    }
                }
            }

<pre lang="Delphi"><pre lang="Delphi">
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900