我正在尝试检索 commandOutput 的输出,以便将其传递给另一个函数,但 commandCompleted 从未运行过。有什么帮助吗?
Command command = new Command(0, "cat " + file){
private String output;
@Override
public void commandCompleted(int id, int exitCode) {
Log.d("Commands.Completed", output);
Log.d("Commands.Completed", "ID: " + id + " & exitCode: " + exitCode);
saveData(output);
}
@Override
public void commandOutput(int id, String line) {
output += line + "\n";
}
@Override
public void commandTerminated(int id, String reason) {
}
};
try {
RootTools.getShell(true).add(command);
} catch (IOException | RootDeniedException | TimeoutException e) {
e.printStackTrace();
}