简体   繁体   中英

run “adb shell” programmatically

Is there a way to start adb shell from application/java code? I have followed below method. But everytime it only shows "device not found". However am able to get the logs if am executing "adb logcat -f /storage/emulated/0/logs.txt &" .I have even enabled USB debugging on the device. Kindly help me if any1 knows any other alternative.

try{
 Runtime runtime = Runtime.getRuntime();
 Process process = runtime.exec("adb shell");
}
catch(Exception e){
}
try {
   Runtime runtime = Runtime.getRuntime();

   Process process = runtime.exec("E:\\Android\\sdk\\platform-tools\\adb shell");
   } catch (Exception e) {
   System.out.println("dasd");
}

E:\\Android\\sdk\\platform-tools\\ is my path of adb,(replays with yuors)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM