相关疑难解决方法(0)

Android:写入失败:EPIPE(Broken pipe)写入文件出错

我试图以编程方式截取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();
    }
}
Run Code Online (Sandbox Code Playgroud)

java.io.IOException: write failed: EPIPE (Broken pipe)

请有人帮忙吗?我已经检查过其他帖子,但我找不到解决问题的方法.


编辑:

请注意,错误发生在行中os.write().

android outputstream file epipe android-permissions

18
推荐指数
1
解决办法
3万
查看次数

标签 统计

android ×1

android-permissions ×1

epipe ×1

file ×1

outputstream ×1