public static void screenShot(){
try {
Process sh = Runtime.getRuntime().exec("sh");
//Process sh = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(sh.getOutputStream());
os.writeBytes(("screencap -p /sdcard/screenshot.png"));
os.flush();
os.close();
sh.waitFor();
}catch (Exception e){
e.printStackTrace();
}
}
exec("su")不行的话就exec("sh"),因为这条命令是需要在root进程中使用
本文介绍了一种在Android设备上进行屏幕截图的方法,该方法通过调用系统的screencap命令并将截图保存到SD卡上。文章提供了一个Java静态方法实现,并说明了在不同权限环境下如何选择合适的命令执行方式。
9242

被折叠的 条评论
为什么被折叠?



