[英]How to Screen Capture With Own android Service without Rooted Device?
[英]Android screen capture on rooted device
在root设备上的屏幕截图我想捕获使用APK生成的Android设备的屏幕。 我试过了
process = Runtime.getRuntime().exec("/system/bin/screencap -p " + path + ”/file.png ”);
这个命令工作正常但速度太慢。 然后我尝试使用第二个选项
View content = findViewById(android.R.id.content).getRootView();
content.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(content.getDrawingCache());
OutputStream fout = null;
File imageFile = new File(_path,"ScreenImage.png");
try {
fout = new FileOutputStream(imageFile);
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fout);
fout.flush();
fout.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
但在这里,我正在查看我的应用程序而非当前屏幕。 我是捕捉屏幕截图一个制作视频从他们我使用FB0制作视频,但问题是捕获屏幕速度为每秒8帧
请建议加速此过程的解决方案。 分辨率不是问题,可能是质量差。
由于您的设备已植根,请查看framework hide api SurfaceControl的截屏方法。 没有测试它是否足够快。
public static Bitmap screenshot(int width, int height) {
// TODO: should take the display as a parameter
IBinder displayToken = SurfaceControl.getBuiltInDisplay(
SurfaceControl.BUILT_IN_DISPLAY_ID_MAIN);
return nativeScreenshot(displayToken, width, height, 0, 0, true);
}
截取屏幕截图的正常步骤是拦截PhoneWindowManager中的屏幕截图组合键,然后连接到systemui中的截屏服务,此服务将调用方法SurfaceControl.screenshot来截取屏幕截图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.