Mohammad abumazen
Mohammad abumazen

Reputation: 1286

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?

Upvotes: 7

Views: 572

Answers (1)

matreshkin
matreshkin

Reputation: 2208

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.

Upvotes: 3

Related Questions