简体   繁体   中英

Android app crashes when adding commands to RootTools v4.2 shell

I have an Android application utilizing RootTools v4.2 (the latest I know of) and I have followed their documentation on how to execute shell commands as root. Sometimes the commands execute just fine, other times the app crashes with the following exception.

java.lang.IllegalStateException: Unable to add commands to a closed shell

Here is the actual code the exception is being throw on:

RootTools.getShell(true).add(cmd);

So I'm wondering since the docs make no mention of this sort of problem if there is something else I'm doing wrong? Looking through the docs I see nothing on how to ensure I get an open shell before I start adding commands.

This code is working with me . Try to install the Library again may be its not vaild .

if(RootTools.isAccessGiven()){
try {
    Shell shell = RootTools.getShell(true);
    JavaCommand cmd = new JavaCommand(0,this,"input keyevent 26");
    shell.add(cmd);
}
catch (Exception e){
    Log.d("ERRORS : ",e.getMessage());
}
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM