我想将一个应用程序安装在 android root 设备上作为 java 应用程序的系统应用程序.. 为此我必须执行以下命令
adb remount
adb shell
su
cd /data/app/
ls com.mypackage *
然后必须检查是否安装了具有此包名称的应用程序,之后必须执行以下命令
mv com.mypackage.apk /system/app/com.mypackage.apk
exit
exit
adb reboot
有什么想法可以实现这一点吗?
最佳答案
尝试在应用程序中使用进程构建器来运行 adb 命令。
示例
String[] command = {"ls", "-s"}; // Mention your list of commands here
StringBuilder cmdReturn = new StringBuilder();
try {
ProcessBuilder processBuilder = new ProcessBuilder(command);
Process process = processBuilder.start();
InputStream inputStream = process.getInputStream();
int c;
while ((c = inputStream.read()) != -1) {
cmdReturn.append((char) c);
}
prompt.setText(cmdReturn.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
关于java - 无法从java应用程序执行连续的adb命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27722547/