# 安卓里执行adb

新建个方法

   public  void   runCommand (String cmd){
        DataOutputStream dos = null;
       try{
           Process p = Runtime.getRuntime().exec("su");
           dos = new DataOutputStream(p.getOutputStream());
           dos.writeBytes(cmd + "\n");
           dos.flush();
           dos.writeBytes("exit\n");
           dos.flush();
       }catch (Exception e) {

       }
    }
1
2
3
4
5
6
7
8
9
10
11
12
13

重启设备

 runCommand("reboot");
1