Can anyone say, whether adb
commands can be executed through my android application. If it is possible to execute, how it can be implemented?
To use ADB with your Android device, you must enable a feature called “USB Debugging.” Open your phone's app drawer, tap the Settings icon, and select “About Phone”. Scroll all the way down and tap the “Build Number” item seven times. You should get a message saying you are now a developer.
Use the -s option followed by a device name to select on which device the adb command should run. The -s options should be first in line, before the command.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With