韌館-LearnHouse

Archive for 23 7 月, 2020

[Android]用程式執行adb shell指令

開發APP有時候會遇到想直接用shell指令的方式來執行想要的程式,而不想為了一個功能寫了一堆Java code
透過程式執行shell指令有兩中方式,一種是只要執行,不管執行結果的回覆內容比較簡單,如下:

try {
    Runtime.getRuntime().exec("you shell command");
} catch (Exception e) {
    Log.e("Error: ", e.getMessage());
}

Read more...

2020年7 月 posted by admin in 程式&軟體 and have No Comments