- If there are more than one Android device connected (including emulators), it only gets screenshots from the first one we find. Ideally there would be a way to list devices and select which one we want to use.
- Not at all configurable.
AndroidDebugBridge.init(false); AndroidDebugBridge adb = AndroidDebugBridge.createBridge();2. Set up a listener (an implementation of the IDeviceChangeListener interface) for device changes and add it:
Screenshot ss = new Screenshot(); AndroidDebugBridge.addDeviceChangeListener(ss);3. Wait for a device to be connected
4. Get a list of connected devices:
Device[] devices = adb.getDevices();5. In a loop, grab a raw image from the device, then save it as a PNG:
raw = device.getScreenshot();
PaletteData pal = new PaletteData(0xf800, 0x07e0, 0x001f);
ImageData image = new ImageData(raw.width, raw.height, raw.bpp, pal, 1, raw.data);
ImageLoader loader = new ImageLoader();
loader.data = new ImageData[] { image };
loader.save(filename, SWT.IMAGE_PNG);
And that's it. There's a lot more functionality in ddmlib.jar that could be useful for automating tasks like this.