安卓:写失败:EPIPE(管道中断)错误上写文件 [英] Android: write failed: EPIPE (Broken pipe) Error on write file
问题描述
我试图采取了Android屏幕截图编程。我做了以下code:
私人无效getsnap(){
尝试{
过程SH =调用Runtime.getRuntime()EXEC(素,NULL,NULL);
OutputStream的OS = sh.getOutputStream();
字符串文件路径= this.getFilesDir()getPath()的toString()+/fileName1.jpeg。
os.write((/系统/斌/ screencap -p+文件路径).getBytes(ASCII));
os.flush();
os.close();
sh.waitFor();
}
赶上(例外五)
{
e.printStackTrace();
}
}
java.io.IOException异常:写失败:EPIPE(断管)
请能有人帮忙吗?我已经检查了其他职位,我不找到任何解决我的问题。
编辑:
请注意,错误发生在该行 os.write()
。
EPIPE问题通常是因为你要么尝试执行命令,需要root权限( getRuntime()。EXEC
)你的情况没有在设备上或者同时运行几个根命令。如果您在模拟器上工作,需要铲除它,我想你的模拟器运行时,你可以试试这个:
亚行外壳安装邻RW,重新挂载-t YAFFS2的/ dev /块/ mtdblock03 /系统
亚行推动苏/系统/ XBIN /苏
亚行外壳搭配chmod 06755 /系统
亚行外壳搭配chmod 06755 /系统/ XBIN /苏
在这里<一个href="http://abd-tech.blogspot.com/2011/05/test-root-apps-on-android-emulator.html">http://abd-tech.blogspot.com/2011/05/test-root-apps-on-android-emulator.html更详细的解释。
I was trying to take screenshot of the Android screen programatically. I had done the following code:
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)
Please can someone help? I had already checked the other posts and I dont find anything solving my issue.
EDIT:
Please note, the Error happens in the line os.write()
.
EPIPE issue usually happens when you either try to execute command which needs root permissions (getRuntime().exec
) in your case on the device without it or run several root commands simultaneously. If you work on the emulator and need to root it I think you you can try this while the emulator is running:
adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock03 /system
adb push su /system/xbin/su
adb shell chmod 06755 /system
adb shell chmod 06755 /system/xbin/su
Here http://abd-tech.blogspot.com/2011/05/test-root-apps-on-android-emulator.html more detail explanation.
这篇关于安卓:写失败:EPIPE(管道中断)错误上写文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!