public class USBDeviceDetectorManager extends Object implements Closeable
| Constructor and Description |
|---|
USBDeviceDetectorManager() |
USBDeviceDetectorManager(long pollingInterval)
Creates a new USBDeviceDetectorManager
|
USBDeviceDetectorManager(long pollingInterval,
AbstractStorageDeviceDetector customDeviceDetector)
Creates a new USBDeviceDetectorManager
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addDriveListener(IUSBDriveListener listener)
Adds an IUSBDriveListener.
|
void |
close() |
List<USBStorageDevice> |
getRemovableDevices()
Gets a list of currently attached USB storage devices.
|
boolean |
removeDriveListener(IUSBDriveListener listener)
Removes an IUSBDriveListener.
|
void |
setPollingInterval(long pollingInterval)
Sets the polling interval
|
void |
unmountStorageDevice(USBStorageDevice usbStorageDevice) |
public USBDeviceDetectorManager()
public USBDeviceDetectorManager(long pollingInterval)
The polling interval is used as the update frequency for any attached listeners.
Polling doesn't happen until at least one listener is attached.
pollingInterval - the interval in milliseconds to poll for the USB
storage devices on the system.public USBDeviceDetectorManager(long pollingInterval,
AbstractStorageDeviceDetector customDeviceDetector)
The polling interval is used as the update frequency for any attached listeners. Instead of automatic OS detection a custom StorageDeviceDetector will be used for polling.
Polling doesn't happen until at least one listener is attached.
pollingInterval - the interval in milliseconds to poll for the USB
storage devices on the system.customDeviceDetector - the device detector to usepublic void setPollingInterval(long pollingInterval)
pollingInterval - the interval in milliseconds to poll for the USB
storage devices on the system.public boolean addDriveListener(IUSBDriveListener listener)
The polling timer is automatically started as needed when a listener is added.
listener - the listener to be updated with the attached drivespublic boolean removeDriveListener(IUSBDriveListener listener)
The polling timer is automatically stopped if this is the last listener being removed.
listener - the listener to removepublic List<USBStorageDevice> getRemovableDevices()
This method has no effect on polling or listeners being updated
public void unmountStorageDevice(USBStorageDevice usbStorageDevice) throws IOException
IOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2022. All rights reserved.