带HID USB的Android [英] Android with HID USB
问题描述
亲爱的所有人;
我有一个HID USB设备,我使用c#构建了一个Windows应用程序,然后在添加VendorID和ProductID后成功连接,类的设备= 03,subClass = 01,Portocol = 0;
我尝试在Android上构建应用程序并尝试连接它之后,检测到它移动,但在我的应用程序中它没有被检测到,但我已经尝试了其他设备Class = 02和Class = 01他们被检测到,
所以我搜索了我有发现Class03被用作Android USB常量,因此它将被列入黑名单,因此我要求制造商将固件更改为class = 01,并且在完成它之后,仍然无法正常工作。
有一个我的应用程序代码示例:
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 :
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");
}
}
}
所以我对我的代码有疑问有一个问题或这个设备不兼容,但为什么它在c#应用程序上读取但在Android应用程序上没有。或者我还需要在我的apk中添加设置
请注意,我已经尝试过我的apk连接到智能卡读卡器,USB主机,蓝牙设备等等设备和所有都是class = 01和class = 2并且正在读取。
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 .
推荐答案
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>< pre lang =Delphi> < pre lang =Delphi>< / pre>< / pre>< / pre>
这篇关于带HID USB的Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!