How to Execute Adb Commands Through My Android App

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

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.

How to execute commands on a 3rd party app using adb commands or something similar

Take a look at UiAutomator.
It will enable you to launch a third-party app and perform any actions you want with it. In order to examine the UI and create the right locators, there's a command-line tool called uiautomatorviewer, bundled along with Android SDK.



Related Topics



Leave a reply



Submit