Android画面のスクリーンショットをプログラムで撮ろうとしていました。私は次のコードを実行しました:
private void getsnap(){
try{
Process sh = Runtime.getRuntime().exec("su", null, null);
OutputStream os = sh.getOutputStream();
String filePath = this.getFilesDir().getPath().toString() + "/fileName1.jpeg";
os.write(("/system/bin/screencap -p " + filePath).getBytes("ASCII"));
os.flush();
os.close();
sh.waitFor();
}
catch (Exception e)
{
e.printStackTrace();
}
}
java.io.IOException: write failed: EPIPE (Broken pipe)
誰か助けてください。私はすでに他の投稿をチェックしていましたが、私の問題を解決するものは何も見つかりません.
編集:
エラーは行で発生することに注意してくださいos.write()
。