我正在努力与通过 WiFi 连接的多个表(全部有根)共享平板电脑显示屏,我正在使用以下方法(全部在一个线程中):
1- 我截屏。
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- 压缩屏幕截图图像。
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- 打开套接字并将压缩图像发送到另一台平板电脑。
这是有效的,但我的问题是在另一台平板电脑上的观看延迟需要 4-5 秒来刷新新显示器,是否有更好的方法让它实时显示?
最佳答案
不幸的是,这个功能需要很长时间。它与进程生命周期、IPC 和慢速文件系统相关联。你需要看看 this library或 source code of /system/bin/screenshot util.您必须从源代码中重用 native (c 语言)函数,这不是一项简单的任务。
关于Android 在其他设备上共享显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16948607/