Android share display on another devices

血红的双手。 提交于 2019-12-10 13:08:02

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/16948607/android-share-display-on-another-devices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!