android 命令修改dns,在android中使用内部linux命令的x+ 4,如何更改 DNS?_dns_开发99编程知识库...
我不確定你需要編輯哪些文件,但這應該給你那些你需要做的工具。我已經給了一些示例代碼 below 來幫助你。 你可以在 OnClick() 中執行這個按鈕。/*** Runs the shell command.** @param command an array of Strings. command[0] contains the name of the* shell command. comm
我不確定你需要編輯哪些文件,但這應該給你那些你需要做的工具。
我已經給了一些示例代碼 below 來幫助你。 你可以在 OnClick() 中執行這個按鈕。/**
* Runs the shell command.
*
* @param command an array of Strings. command[0] contains the name of the
* shell command. command[1]... contains parameters.
*
* @return the text outputted by the command to stderr or stdout
*/
String runCmd(String[] command, boolean readOutput,
boolean waitForExit) {
ProcessBuilder probuilder = new ProcessBuilder()
. command(command)
. redirectErrorStream(true);
String output ="";
Process process;
//Log.d("MyShellCommand","Executing" + command[0]);
try {
process = probuilder.start();
} catch(IOException e) {
return e.getMessage();
}
if (readOutput) {
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
try {
while ((line = br.readLine())!= null) {
//Log.d("MyShellCommand","Read a line:" + line);
output += line +"n";
}
} catch(IOException e) {
output = e.getMessage();
}
}
更多推荐
所有评论(0)