How to read output of android process command
Posted
by
kevdliu
on Stack Overflow
See other posts from Stack Overflow
or by kevdliu
Published on 2012-06-29T03:11:50Z
Indexed on
2012/06/29
3:15 UTC
Read the original article
Hit count: 148
I am trying to get the output of android shell command 'getprop' with java since getprop() always returns null no matter what.
I tried this from developer.android.com:
Process process = null;
try {
process = new ProcessBuilder()
.command("/system/bin/getprop", "build.version")
.redirectErrorStream(true)
.start();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
InputStream in = process.getInputStream();
//String prop = in.toString();
System.out.println(in);
process.destroy();
However what is printed is not the output but a bunch of characters and numbers (dont have the exact output right now).
How can i get the output of the process?
Thanks!
© Stack Overflow or respective owner