How to run an adb command through a Java file?

前端 未结 1 817
悲哀的现实
悲哀的现实 2021-01-07 12:02

I have written the following code and cannot quite figure out how to solve the error. Not sure if this information will be found useful, but I am using a Mac and using the e

相关标签:
1条回答
  • 2021-01-07 12:06

    You need to use the exec(String[] cmdarray) function to send arguments, the single argument version of the function splits the string on space, and that spells trouble if your path contains spaces.

    you also need to specify the full path (maybe /usr/bin/adb?).

    Like this:

    Process process = runtime.exec(new String[] {"/usr/bin/adb", "devices"});
    
    0 讨论(0)
提交回复
热议问题