Skip to content
lltodoll edited this page Nov 17, 2019 · 1 revision

Welcome to the Java-MTP-Autodetector wiki!

Usage

You must implemented the IAutodetectorListener on your Swing Component / Consolencomponent:

Listener

` IAutodetectorListener autodetectorListener = new IAutodetectorListener() {

		public void newDevice(PortableDevice portableDevice)
		{
			System.out.println("NewDevice: " + portableDevice);
		}

		@Override
		public void removeDevice(PortableDevice portableDevice)
		{
			System.out.println("RemovedDevice: " + portableDevice);
		}
	};

`

After that you can start the Autodetector Thread. This Thread notifiy all listener if a new device connected or an old device disconnect. All PortableDevices are already open in newDevice and will be close after calling removeDevice. So you dont need open or close the Portable Device.

AutodetectorThread

AutodetectorThread autodetectorThread = new AutodetectorThread(this);

autodetectorThread.start();

Clone this wiki locally