Android开发执行adb 命令行命令

时间:2014-06-24 18:04:18   收藏:0   阅读:291

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 命令行命令,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!