1.在Android开发中调用adb命令进行应用安装,将应用安装到 /system/app目录下
/** * install the app in use adb command,this style is silent * */ private void adbInstallTheAPP(){ //adb push core code String command = "cp" + "the android apk file path" + "/system/app"; Process process = null; DataOutputStream os = null; try { process = Runtime.getRuntime().exec("su");// the phone must be root,it can exctue the adb command os = new DataOutputStream(process.getOutputStream()); os.writeBytes(command + "\n"); os.writeBytes("exit\n"); os.flush(); } catch (Exception e) { e.printStackTrace(); } }
2.如果需要用adb reboot重启手机,可以使用下面命令
String command = "adb reboot";
注意:使用该adb 命令行 命令前提是 手机已经root 否则,无法执行安迪板命令
Android开发执行adb 命令行命令
时间: 2024-12-20 17:12:16