Search code examples
androidadb

Is it possible to execute adb commands through my android app?


Can anyone say, whether adb commands can be executed through my android application. If it is possible to execute, how it can be implemented?


Solution

  • You can do it with this:

    Process process = Runtime.getRuntime().exec("your command");
    BufferedReader bufferedReader = new BufferedReader(
    new InputStreamReader(process.getInputStream()));
    

    Don't forget to surround it with a try and catch statement.

    Edit:

    @Phix is right, ProcessBuilder would be better to use.