1

I am trying to take screenshot an a rooted android phone locally. I want to take screenshot of other activites, via a service. The only requirement is that the screenshot should be atmost ~ 100ms.

I try

java.lang.Process process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os.writeBytes("cat /dev/graphics/fb0 > " + raw + "\n");
os.writeBytes("exit\n");
os.flush();
os.close();
process.waitFor();

but as i try to write it to a file, it takes a bit too long!

Also, as I am trying to do this locally on the phone, without connecting it to the PC.

Kay
  • 51
  • 6
  • 1
    as i said, I am trying to do this locally on the phone. – Kay Dec 17 '12 at 07:14
  • You might get better performance using Android NDK. This post has some stuff related to file operations with NDK: http://stackoverflow.com/questions/1992953/file-operations-in-android-ndk – 1615903 Dec 17 '12 at 07:28

2 Answers2

0

This is not supported and may or may not work on all devices. You might also get something that is not in a format you are expecting. If you are using a 4.0+ device you can see how they implement the system screenshot functionality and emulate that. There are also a couple of small utilities in AOSP, screencap and screenshot, you might want to look at their code (in frameworks/base/cmds.

Nikolay Elenkov
  • 52,576
  • 10
  • 84
  • 84
0

You can use adb command to take the screenshot adb shell screencap -p /mnt/sdcard/screen.png and execute it programatically from the applicaiton

Akhil Dabral
  • 760
  • 1
  • 10
  • 11