Android 在其他设备上共享显示

标签 android screen screenshot

我正在努力与通过 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 librarysource code of /system/bin/screenshot util.您必须从源代码中重用 native (c 语言)函数,这不是一项简单的任务。

关于Android 在其他设备上共享显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16948607/

相关文章:

iphone - iTunes Lookup API,获取iPhone 5应用程序截图

android - 在 Android list 文件中添加 uses-sdk 字段会导致崩溃

使用非测试人员 Facebook 帐户的 Android Facebook 登录错误

linux - 没有Ubuntu Synergy指针

android - 使用 canvas.drawBitmap() 填充屏幕

java - 如何在java中获得屏幕分辨率?

c - 在 C 中创建 BITMAP 时初始化程序无效

android - 处理cameraX的图像分析时,JS UI被阻止

android - Android Studio 查看 XML 布局时出错

.net - 使 .NET 截图工具与多个监视器兼容