Osama Gamal
Osama Gamal

Reputation: 1231

How to run terminal command in Android application?

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?

Upvotes: 16

Views: 31940

Answers (3)

Josh Gao
Josh Gao

Reputation: 2564

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

Upvotes: 13

NickUnuchek
NickUnuchek

Reputation: 12887

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

Upvotes: 1

Osama Gamal
Osama Gamal

Reputation: 1231

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

Upvotes: 1

Related Questions