我试图检索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();
}发布于 2016-04-20 22:03:17
缺少您的commandCompleted(int id, int exitCode)实现
super.commandCompleted(id, exitCode);可能是问题所在吗?
如果将RootTools导入为
import com.stericson.RootTools.*;你也可以使用RootTools.Log,默认情况下它是静音的。也许可以试着用
android.util.Log.d("Commands.Completed", output);只是为了排除这种情况。
https://stackoverflow.com/questions/32799708
复制相似问题