我尝试列出所有连接到我的android平板电脑上的usb设备。我使用https://play.google.com/store/apps/details?id=hu.sztupy.android.usbhostcontroller&hl=en来检查设备是否能识别use键盘,是的,它在两个平板电脑上都能识别,而且tastatur在两个平板电脑上都能工作。代码看起来像这样
UsbManager mUsbManager;
mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
mUsbManager.getDeviceList();
HashMap<String, UsbDevice> deviceList = mUsbManager.getDeviceList();
Iterator<UsbDevice> deviceIterator = deviceList.values().iterator();
this.outputtext.append(deviceList.size()+"Geräte gefunden");
this.outputtext.append(mUsbManager.toString());
UsbDevice device=null;
while(deviceIterator.hasNext()){
device = deviceIterator.next();
this.outputtext.append( device.getDeviceName()+" vendorid: "+device.getVendorId()+" productid"+device.getProductId());
}奇怪的是,它在我的爱可思钛hd上工作,但在我的富士通m532上不起作用。我做错了什么?
诚挚的问候
发布于 2017-11-02 18:00:32
只需检查您的富士通m532的API级别,因为getSystemService()要求最低API级别为23 (Android版本6.0)。
https://stackoverflow.com/questions/17975122
复制相似问题