Execute ADB command from Java program

前端 未结 4 1824
死守一世寂寞
死守一世寂寞 2020-12-09 06:38

The program I\'m working on uses ADB (Android Debug Bridge) to send files to my phone:

for (String s : files)
    String cmd = \"adb -s 0123456789ABCDEF push         


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-09 06:54

     public static void adbpush() {
            System.out.println("adb push....");
            String[] aCommand = new String[] { adbPath, "push", inputFile(String),OutputDirectory };
            try {
                // Process process = new ProcessBuilder(aCommand).start();
                Process process = Runtime.getRuntime().exec(aCommand);
                process.waitFor(3, TimeUnit.SECONDS);
                System.out.println("file pushed");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    

提交回复
热议问题