We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/** * 获取屏幕截图 * * @return 截图路径 */ public static String screenCap() { try { Process sh = Runtime.getRuntime().exec("su", null, null); OutputStream os = sh.getOutputStream(); os.write("/system/bin/screencap -p /sdcard/screen.png".getBytes()); os.flush(); os.close(); sh.waitFor(); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } return screenName; }
The text was updated successfully, but these errors were encountered:
使用系统命令 /system/bin/screencap -p filename 进行截屏并保存到filename。以上代码是在android中启动系统进程运行命令完成截屏操作。
/system/bin/screencap -p filename
另外还有一个命令 /system/bin/screenshot, 这个命令保存的图片会错位,不知道什么原因。
/system/bin/screenshot
Sorry, something went wrong.
No branches or pull requests
The text was updated successfully, but these errors were encountered: