Environment :Ubuntu jdk1.8 eclipse
String []cmdHeader={"/bin/bash","-c","adb"};
Runtime cmd=Runtime.getRuntime();;
Process p=cmd.exec(cmdHeaher);;
BufferedReader br=
new BufferedReader(
new InputStreamReader(p.getInputStream()));
String line=br.readLine();
while(line!=null){
System.out.println(1);
System.out.println(line);
line=br.readLine();
}
br.close();
There are some details I omitted.
In this cmd,the console shows nothing.Why?
ps: adb is ok when I run it on bash window.
On your command line, execute which adb
. This will give you the full path to the adb
command, e.g. /usr/local/bin/adb
.
Then in your code replace adb
with the full path you got from the command line, for example:
String[] cmdHeader = {"/bin/bash","-c","/usr/local/bin/adb"};