2016-09-27 101 views
0

我试图创建一个可以检测到USB设备的应用程序。 Android设备就像一个主机,我现在只需要读取连接设备的数据。问题在Android中获取USB设备版本

我导入android.hardware.usb.UsbDevice

所有工作正常,但问题是任何usbDevice方法。我可以读取usbDevice.getDeviceName()方法,但我不能使用例如getVersion(),whY?

他说我cannos解决这个方法。还有关于其他方法。

private String readDevice(UsbDevice device) { 

     StringBuilder sb = new StringBuilder(); 
     String a = device.getDeviceName(); //work 
     String b = device.getVersion(); //doesn't work 

} 

回答

1

您需要阅读This Link

它包含在API 23

String versionStr = UsbDevice.getVersion(); 

或者你可以帮助从This Link