Yes Renas I am not able to call the Screenshot class.
Below are the logs
I/System.out( 327): 38:08 E/DeviceMonitor: Failed to read the adb
response!
I/System.out( 327): 38:08 E/DeviceMonitor: Adb connection
Error:Failed to read the adb response!
I/System.out( 327): 38:08 E/DeviceMonitor: adb refused request:
closed
I/System.out( 327): 38:08 E/DeviceMonitor: Failed to read the adb
response!
I/System.out( 327): 38:08 E/DeviceMonitor: Adb connection
Error:Failed to read the adb response!
I/System.out( 327): 38:08 E/DeviceMonitor: adb refused request:
closed
I/System.out( 327): 38:08 E/DeviceMonitor: Failed to read the adb
response!
I/System.out( 327): 38:08 E/DeviceMonitor: Adb connection
Error:Failed to read the adb response!
I/System.out( 327): 38:08 E/DeviceMonitor: adb refused request:
closed
I/System.out( 327): 38:08 E/DeviceMonitor: Failed to read the adb
response!
I/System.out( 327): 38:08 E/DeviceMonitor: Adb connection
Error:Failed to read the adb response!
I/System.out( 327): 38:08 E/DeviceMonitor: adb refused request:
closed
I/System.out( 327): 38:08 E/DeviceMonitor: Failed to read the adb
response!
I/System.out( 327): 38:08 E/DeviceMonitor: Adb connection
Error:Failed to read the adb response!
I/System.out( 327): 38:08 E/DeviceMonitor: adb refused request:
closed
I/System.out( 327): 38:08 E/DeviceMonitor: Failed to read the adb
response!
I/System.out( 327): 38:08 E/DeviceMonitor: Adb connection
Error:Failed to read the adb response!
D/dalvikvm( 327): GC_FOR_MALLOC freed 15031 objects / 524544 bytes in
115ms
I/System.out( 327): 38:09 E/DeviceMonitor: adb refused request:
closed
I/System.out( 327): 38:09 E/DeviceMonitor: Failed to read the adb
response!
I/System.out( 327): 38:09 E/DeviceMonitor: Adb connection
Error:Failed to read the adb response!
I/System.out( 327): 38:09 E/DeviceMonitor: adb refused request:
closed
I/System.out( 327): 38:09 E/DeviceMonitor: Failed to read the adb
response!
These logs will come continuously till i close emulator manually.
-----------------------------------------------------------------------------------------------------------------------------
Below is my sample code which calls Screenshot class
public class AIMTest extends ActivityInstrumentationTestCase2{
private static final String TARGET_PACKAGE_ID =
"aol.client.aim";
private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME =
"aol.client.aim.AIM";
private static Class<?> launcherActivityClass;
static{
try {
launcherActivityClass =
Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
//@SuppressWarnings("unchecked")
public AIMTest() throws ClassNotFoundException {
super(TARGET_PACKAGE_ID, launcherActivityClass);
}
private Solo solo;
protected void setUp() throws Exception {
solo = new Solo(getInstrumentation(), getActivity());
}
//public void testCanOpenSettings(){
// solo.pressMenuItem(0);
// }
public void testAddNote() throws Exception {
Thread.sleep(5000);
solo.clickOnMenuItem("Settings");
Thread.sleep(2000);
new Screenshot(); //calling Screenshot class
}
public void tearDown() throws Exception {
try {
solo.finalize();
} catch (Throwable e) {
e.printStackTrace();
}
getActivity().finish();
super.tearDown();
}
}
---------------------------------------------------------------------------------------------------------------------------------------------------
Below is the Screenshot class
public class Screenshot implements IDeviceChangeListener {
private static final int SCREENSHOT_INTERVAL = 300;
private static boolean mConnected = false;
private static int i=1;
public Screenshot() {
try {
AndroidDebugBridge.init(false);
AndroidDebugBridge adb = AndroidDebugBridge.createBridge();
AndroidDebugBridge.addDeviceChangeListener(this);
System.out.print("Waiting for device connection...\n");
synchronized (this) {
this.wait();
}
IDevice[] devices = adb.getDevices();
if(devices.length > 0) {
getScreenshots(this, devices[0]);
}
System.out.print("Done\n");
} catch (InterruptedException e) {
} finally {
// close the debug bridge
AndroidDebugBridge.terminate();
}
}
private static void getScreenshots(Screenshot ss, IDevice device)
throws InterruptedException {
String thisDevice = device.getSerialNumber();
SimpleDateFormat datefmt = new SimpleDateFormat("yyyyMMdd-HHmmss");
String dir = String.format("%s-%s", thisDevice, datefmt.format(new
Date()));
if (new File(dir).mkdir() == false) {
System.out.printf("Couldn't create directory %s", dir);
return;
}
System.out.printf("Writing files to directory %s\n", dir);
// get images until the device is disconnected
int count = 0;
while (i==1) {
RawImage raw = null;
try {
raw = device.getScreenshot();
} catch (IOException e) {
System.out.printf("Error getting image: %s\n", e.getMessage());
}
if (raw != null) {
String filename = String.format("%s%s%08d.jpg", dir,
File.separator, count);
// save raw data to png
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);
System.out.printf("Saved picture as %s\n", filename);
count++;
i++;
}
synchronized(ss) {
ss.wait(SCREENSHOT_INTERVAL);
}
}
}
@Override
public void deviceChanged(IDevice device, int changeMask) {
}
@Override
public void deviceConnected(IDevice device) {
System.out.printf("Device %s connected\n",
device.getSerialNumber());
mConnected = true;
synchronized (this) {
notify();
}
}
@Override
public void deviceDisconnected(IDevice device) {
System.out.printf("Device %s disconnected\n",
device.getSerialNumber());
mConnected = false;
synchronized (this) {
notify();
}
}
}
Please give me the solution.
On Aug 5, 12:00 pm, Renas <
renasr...@gmail.com> wrote:
> So you can not call the screen shot class from your test case? What does the
> log say?
>
> /Renas
>
> On Thu, Aug 5, 2010 at 8:29 AM, Kantha <
kanth...@gmail.com> wrote:
> > Hi,
> > I am using Robotium and it is very helpful for me. But now i m
> > in a situation where i need to take screenshot of the emulator, i
> > think currently Robotium dont have any methods or class for taking
> > screenshot.I have a screenshot class which takes screenshot when
> > called independently, but when i called that class inside robotium, i
> > m getting error saying " Test run failed: Process crashed".
>
> > Please help me to get out of this.
>
> > Thanks
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Robotium Developers" group.
> > To post to this group, send email to
robotium-...@googlegroups.com.
> > To unsubscribe from this group, send email to
> >
robotium-develo...@googlegroups.com<
robotium-developers%2Bunsu...@googlegroups.com>
> > .