16

How to send a command to the terminal through android app and get the output back? For example, sending "ls /" and getting the output to print it in the GUI?

3 Answers 3

13

Use Runtime.exec to get a process, waitFor it to finish, and then read its output out of its output and error streams.

Sign up to request clarification or add additional context in comments.

1 Comment

I'm getting "java.lang.ClassNotFoundException: android.os.Exec"
1

Different solutions could be found here: http://code.google.com/p/market-enabler/wiki/ShellCommands I've not tested them yet.

Comments

1

Try this answer there is way to run shell commands on android programmatically https://stackoverflow.com/a/3350332/2425851

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.