2015-09-26 50 views
0

我試圖檢索commandOutput的輸出以便將它傳遞給另一個函數,但commandCompleted從不運行。任何幫助?使用RootTools從完成的命令返回輸出

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(); 
} 

回答

0

commandCompleted(int id, int exitCode)實施缺少

super.commandCompleted(id, exitCode); 

會不會是什麼問題?

如果導入RootTools作爲

import com.stericson.RootTools.*; 

,你還可以使用RootTools.Log其默認處於靜音狀態。也許嘗試使用

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

只是爲了排除這種情況。