Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 232
Mohammad abumazen Avatar asked Jun 05 '13 19:06

Mohammad abumazen


Video Answer


1 Answers

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.

like image 158
matreshkin Avatar answered Oct 21 '22 03:10

matreshkin