public static java.awt.Image | loadCapture(com.android.ddmlib.Device device, com.android.hierarchyviewer.device.Window window, java.lang.String params)
Socket socket = null;
BufferedInputStream in = null;
BufferedWriter out = null;
try {
socket = new Socket();
socket.connect(new InetSocketAddress("127.0.0.1",
DeviceBridge.getDeviceLocalPort(device)));
out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
in = new BufferedInputStream(socket.getInputStream());
out.write("CAPTURE " + window.encode() + " " + params);
out.newLine();
out.flush();
return ImageIO.read(in);
} catch (IOException e) {
// Empty
} finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
if (socket != null) {
socket.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
return null;
|