要执行一个linux命令,比如在创建个test 文件夹,命令 mkdir /root/test。下面是我的 MainActivity.java 代码,求
androidmanifest.xml 如何配置申明,希望给个完整代码,谢谢
public void execCommand(String command) throws IOException {
Runtime runtime = Runtime.getRuntime();
Process proc = runtime.exec( mkdir /root/test);
try {
if (proc.waitFor() != 0) {
System.err.println("exit value = " + proc.exitValue());
}
BufferedReader in = new BufferedReader(new InputStreamReader(
proc.getInputStream()));
StringBuffer stringBuffer = new StringBuffer();
String line = null;
while ((line = in.readLine()) != null) {
stringBuffer.append(line+" ");
}
System.out.println(stringBuffer.toString());
} catch (InterruptedException e) {
System.err.println(e);
}finally{
try {
proc.destroy();
} catch (Exception e2) {
}
}
}
其实我贴的代码就是执行linux命令的,现在要把这个代码里面的用的包如何在
androidmanifest.xml注册或者说是声明
不是在manifest.xml执行liunx命令,是配置申明
追答代码里执行Linux命令不需要在manifest里面声明。不太明白你的意思。