Java 使用RootTools从已完成的命令返回输出
我试图检索commandOutput的输出,以便将其传递给另一个函数,但commandCompleted从未运行过。有什么帮助吗Java 使用RootTools从已完成的命令返回输出,java,roottools,Java,Roottools,我试图检索commandOutput的输出,以便将其传递给另一个函数,但commandCompleted从未运行过。有什么帮助吗 Command command = new Command(0, "cat " + file){ private String output; @Override public void commandCompleted(int id, int exitCode) { Log.d("Commands.Completed", ou
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();
}
您的
命令已完成(int-id,int-exitCode)
实现缺失
super.commandCompleted(id, exitCode);
这可能是问题所在吗
如果将RootTools
导入为
import com.stericson.RootTools.*;
您还可以使用默认为静音的RootTools.Log
。也许试着用
android.util.Log.d("Commands.Completed", output);
只是为了排除这种情况