Any way to run shell commands on android programmatically?

android, linux

Solution

Check out Log Collector as an example. Here is the relevant file.

The key is here:

ArrayList<String> commandLine = new ArrayList<String>();
commandLine.add("logcat");//$NON-NLS-1$
[...]

Process process = Runtime.getRuntime().exec(commandLine);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));

Problem

Is there any way to run terminal commands on my application and then access the data on my UI? Specifically `top`.

Original source