java - 以编程方式运行 adb 命令 Android
问题描述
在运行测试用例之前,我试图在 Android 中以编程方式运行 adb 命令。但我得到以下异常
runShellCommand exception - Error running exec(). Command: [adb, shell, settings, put, secure, immersive_mode_confirmations, confirmed] Working Directory: null Environment: null
private void runShellCommand(String command) {
Timber.d("runShellCommand");
try {
Process process = Runtime.getRuntime().exec(command);
process.waitFor();
} catch (IOException | InterruptedException e) {
Timber.d("runShellCommand exception - " + e.getMessage());
e.printStackTrace();
}
}
这就是我使用 adb 命令调用该函数的方式
runShellCommand("adb shell settings put secure immersive_mode_confirmations confirmed");
有关如何解决此问题的任何建议,请
谢谢R
解决方案
推荐阅读
- mysql - 如何获取具有相同名称、编号和城市的重复值?
- javascript - Javascript数组合并具有相同键值的对象
- go - 它是并发的,但是是什么让它并行运行呢?
- python - 在 Python 3.8 中缩进请修复
- android - 想在android中新捕获的图像上添加一些文本
- excel - Range.ClearContents 干扰粘贴宏
- javascript - RemoveEventListener click vaadin
- angular - Angular - 反应式表单具有待处理状态
- python - 将行细分为 50 的间隔并取平均值
- typescript - 使用 redux-toolkit 中的 `unwrapResult` 键入自定义 `useDispatch` 钩子