It seems straightforward enough.
I'm using Runtime.getRuntime().exec(commandString);
I've tried
String commandString = "logcat -v raw --pid=" + PID);
Runtime.getRuntime().exec(commandString);
I've tried it without the -v raw
and have also tried (and need to) use multiple PIDs using |
.
Nothing seems to work. I have a new BufferedReader(new InputStreamReader(p.getInputStream()));
that gets nothing. If I don't filter on PID it works but prints out everything that hits the logcat which is not very useful.
What am I missing?
Here is the whole block of the important bit.
try {
Runtime.getRuntime().exec("logcat -c").waitFor();
StringBuilder pids = new StringBuilder("");
for (int i = 0; i < PIDs.size(); i++){
pids.append(Integer.toString(PIDs.get(i)));
if (i < PIDs.size() - 1){
pids.append("|");
}
}
String commmandString = "logcat -v raw --pid=" + pids);
p = Runtime.getRuntime().exec(commmandString);
mBufferedReader = new BufferedReader(new InputStreamReader(p.getInputStream()));
} catch (IOException e) {} catch (InterruptedException e) {}
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
p.destroy();
};
});
mThreadAlive = true;
mLoggingThread.start();