anjinkristou

USB Device listing in android

Mar 30th, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1.             UsbManager manager = (UsbManager) xCtx.getSystemService(Context.USB_SERVICE);
  2.             HashMap<String, UsbDevice> devices = manager.getDeviceList();
  3.             Iterator<String> iterator = devices.keySet().iterator();
  4.             while (iterator.hasNext()) {
  5.                 String key = (String) iterator.next();
  6.                 FusionInventory.log(this,key, Log.VERBOSE);
  7.                 UsbDevice mydevice = devices.get(key);
  8.                 Category c = new Category(mCtx, "USBDEVICES");
  9.                 c.put("CLASS", Integer.toString(mydevice.getDeviceClass()));
  10.                 c.put("PRODUCTID", Integer.toString(mydevice.getProductId()));
  11.                 c.put("VENDORID", Integer.toString(mydevice.getVendorId()));
  12.                 c.put("SUBCLASS", Integer.toString(mydevice.getDeviceSubclass()));
  13.                 this.add(c);
  14.             }
Advertisement
Add Comment
Please, Sign In to add comment