0

I'm trying to retrieve the output of commandOutput in order to pass it to another function, but commandCompleted is never ran. Any help?

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();
}
KostasC
  • 1,076
  • 6
  • 20
  • 40
Qu3ntin0
  • 113
  • 1
  • 1
  • 8

1 Answers1

0

Your commandCompleted(int id, int exitCode) implementation is missing

super.commandCompleted(id, exitCode);

could it be the problem?

If you imported RootTools as

import com.stericson.RootTools.*;

you could also be using RootTools.Log which is muted by default. Maybe try to use

android.util.Log.d("Commands.Completed", output);

just to exclude the case.

MaxChinni
  • 1,206
  • 14
  • 21