[英]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. 我有一个Android应用程序利用RootTools v4.2(我知道的最新),我已经按照他们的文档介绍了如何以root身份执行shell命令。 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. 通过文档查看,在开始添加命令之前,我没有看到如何确保打开shell。
This code is working with me . 此代码正在与我合作。 Try to install the Library again may be its not vaild . 尝试再次安装库可能不是它的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());
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.