我似乎无法得到runtime.exec在我的android应用程序工作。我用shell实用程序主试了一下,这里是我使用的代码:不能得到runtime.exec android上工作
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
filesPrinter = (Button) findViewById(R.id.print_files);
filesPrinter.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
try {
Process proc = Runtime.getRuntime().exec("ls");
out = new BufferedWriter(new OutputStreamWriter(proc.getOutputStream()));
in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String line;
while((line = in.readLine()) != null) {
System.out.println(line);
}
System.out.println("Done reading");
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
我没有得到一个错误,但也没有得到任何logcat中。
什么是错误?问题在哪里?在发布之前你有没有阅读过SO FAQ? – ArtemStorozhuk
@Astor这个问题似乎是一个非常有效的问题,即使错误的更多细节可以帮助确实。 – assylias
我做了一个编辑,没有错误,但我没有得到任何输出logcat – MEURSAULT