Android Take Screenshot rooted phone - android

I am capturing screenshot from my android rooted device using
Process process = Runtime.getRuntime().exec("su", null,null);
OutputStream os = sh.getOutputStream();
os.write(("/system/bin/screencap -p " + "/sdcard/img.png").getBytes("ASCII"));
os.flush();
os.close();
process.waitFor();
It works fine as long as the content on the screen is static (image etc). But when I try to take a screenshot when a video is playing, then the screenshot shows a black screen. Is there any other way to do this?

Related

Take ScreenShot of Visible screen Android

I want to take screen shot of any visible screen from background. I don't want to be dependent on activity context. Whatever screen I open in my device like browser or any social app I just want to take screenshot of that.
I tried different approaches but it is depended on activity and we can only take screenshot of current App.
Any help would be appreciated. thanks
Works only for rooted diveces
Process sh = Runtime.getRuntime().exec("su", null,null);
OutputStream os = sh.getOutputStream();
os.write(("/system/bin/screencap -p " + "/sdcard/img.png").getBytes("ASCII"));
os.flush();
os.close();
sh.waitFor();

Run shell command("su") for current screen View

I am trying to execute a shell script from my Android application to get current screen view.
I have got following code working properly on rooted devices only.
Process sh = null;
try
{
Thread thread=new Thread(new Threadcalling ());
thread.start();
sh = Runtime.getRuntime().exec("su");
OutputStream os = sh.getOutputStream();
os.write(("/system/bin/screencap -p " + "/sdcard/img.png").getBytes("ASCII"));
os.flush();
os.close();
sh.waitFor();
}
catch (Exception e){}
What modification should I do to get screen View on non-rooted devices.
Any help will be appreciated. Thank you.
You cannot do this for non-rooted devices, in other words, you app has to be a system app to access other system apps.
EDIT: Maybe this link may help you:
https://code.google.com/p/android-screenshot-library/

How to convert framebuffer to image?

In my application I want to get the screenshot of my rooted device. I am using the following code to achieve this:
Process sh = Runtime.getRuntime().exec("su", null,null);
OutputStream os = sh.getOutputStream();
os.write(("/system/bin/screencap -p " + "/sdcard/img.png").getBytes("ASCII"));
os.flush();
But I am not getting any image stored.

Android share display on another devices

i'm working on share the tablet display with more than one table (all rooted) connected through WiFi , i'm using the following approach (all inside one thread) :
1- i take a screen shot.
Process sh = Runtime.getRuntime().exec("su", null,null);
OutputStream os = sh.getOutputStream();
os.write(("/system/bin/screencap -P " + "/sdcard/test/img.png").getBytes("ASCII"));
os.flush();
os.close();
sh.waitFor();
2- compress the screen shot image.
Bitmap mBitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getPath() + "/test/img.png");
OutputStream outputStream = null;
File file = new File(Environment.getExternalStorageDirectory().getPath() + "/test/img2.png");
outputStream = new FileOutputStream(file);
mBitmap.compress(Bitmap.CompressFormat.JPEG, 15, outputStream);
outputStream.flush();
outputStream.close();
3- open socket and send the compressed image to another tablet.
this is working but my problem is the viewing delay in the other tablet it took 4-5 sec to refresh the new display , is there any better approach to have it real time display?
Unfotrtunately, this function will take long time. It is linked with process lifecycle, IPC and the slow file system. You need to have a look at this library or the source code of /system/bin/screenshot util. You have to reuse native(c-language) functions from sources, and it is not a trivial task.

Take really quick screenshots of Android Phone programmatically

I am taking screenshots of an Android phone from my application by this code
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 when I put this in a service, and try to run infinitely, I get atmost 2 screenshots.
Is there a way to take screenshots really quick? Like 15-20 in a second using ANY way possible?
EDIT : I try to convert them to video later. Any way to make video without dumping it to the file altogether?

Categories

Resources