android - 使用 RootTools 获取 shell 命令的输出
问题描述
我想获取 shell 命令的输出,例如使用RootTools “ls -l”并将其传递给变量或数组,以便我可以操作它。
这是我使用但不起作用的代码。
final StringBuilder s = new StringBuilder();
final Command command = new Command(0, "ls -l") {
public void commandOutput(int id, String line) {
s.append(line);
super.commandOutput(id, line);
System.out.println(s.toString());
}
};
try {
RootTools.getShell(true).add(command);
} catch (IOException | RootDeniedException | TimeoutException e) {
e.printStackTrace();
}
解决方案
推荐阅读
- android - Dagger 应用程序组件未生成
- html - 使用内联样式的简单 flexbox 网格
- python - 如何使用appium查找哪个应用程序在前台
- android - 在后台加载图像并显示加载页面
- css - 在个人站点的根目录下为 GitHub Pages 准备 Jekyll(baseurl 不是不必要的吗?)
- .net - 隐藏扩展时如何避免 AssemblyName.exe.config 混淆?
- php - htaccess 无法将文章 ID 重定向到使用 php slug 函数生成的文章 slug
- firebase - Firebase Stream 功能无法正常工作
- php - 具有多个条件的 laravel 查询更新
- powerbi - Microsoft Power BI:折线图过去 13 周的数据 3 年