码迷,mamicode.com
首页 > 移动开发 > 详细

Android开发执行adb 命令行命令

时间:2014-06-24 18:04:18      阅读:291      评论:0      收藏:0      [点我收藏+]

标签:android   style   class   blog   code   java   

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

Android开发执行adb 命令行命令

标签:android   style   class   blog   code   java   

原文地址:http://blog.csdn.net/qq435757399/article/details/33722953

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!