80,351
社区成员
发帖
与我相关
我的任务
分享
public void getScreenshot(){
Process process = null;
String filePath = "mnt/sdcard/Zpic/" + System.currentTimeMillis() + ".txt";
try {
process = Runtime.getRuntime().exec("su");
PrintStream outputStream;
outputStream = new PrintStream(new BufferedOutputStream(process.getOutputStream(), 8193));
outputStream.println("screencap -p " + filePath);
outputStream.flush();
outputStream.close();
process.waitFor();
} catch (Exception e) {
e.printStackTrace();
} finally {
if(process != null){
process.destroy();
}
}
}