FileDocCategorySizeDatePackage
HotplugListener.javaAPI DocExample869Thu Feb 16 09:42:36 GMT 2006None

HotplugListener

public class HotplugListener extends Object implements UsbServicesListener

Fields Summary
Constructors Summary
Methods Summary
private static java.lang.StringgetDeviceInfo(UsbDevice device)

    try {
      String product = device.getProductString();
      String serial  = device.getSerialNumberString();
      if (product == null) return "Unknown USB device";
      if (serial != null) return product + " " + serial;
      else return product;
    }
    catch (Exception ex) {
    }
    return "Unknown USB device";
  
public voidusbDeviceAttached(UsbServicesEvent event)

    UsbDevice device = event.getUsbDevice();
    System.out.println(getDeviceInfo(device) + " was added to the bus.");
  
public voidusbDeviceDetached(UsbServicesEvent event)

    UsbDevice device = event.getUsbDevice();
    System.out.println(getDeviceInfo(device) + " was removed from the bus.");