当前位置:编程学习 > wap >>

Android中获取USB设备名称

平板用OTG线连接一个设备,获取device对象后用getDeviceName获取的值是:/dev/bus/usb/002/002
但这不是我想要的,我想获取如:Kingston 16G
在device各方法中也没找到正确的方法。

代码如下:
manager = (UsbManager) getSystemService(Context.USB_SERVICE);
HashMap<String, UsbDevice> deviceList = manager.getDeviceList();
Iterator<UsbDevice> deviceIterator = deviceList.values().iterator();
strDeviceNameList="";
while(deviceIterator.hasNext())
{
        device = deviceIterator.next();         
        data.add("Name: " + device.getDeviceName()+"\n"
     + "VID: " + device.getVendorId()
                + "       PID: " + device.getProductId()));
} --------------------编程问答-------------------- 我觉得 Kingston 16G 这样的字符串应该是usb应用层的协议提供的,比如usb的移动硬盘应用。 是不是应该从映射的目录去寻找信息?
补充:移动开发 ,  Android
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,