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进程中使用