我想在android rooted设备上安装一个应用程序,作为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
任何想法我怎么能做到这一点?
答案 0 :(得分:1)
尝试在应用程序中使用流程构建器来运行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();
}