Skip to content

Instantly share code, notes, and snippets.

@adrianoschmidt
Last active October 13, 2015 00:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adrianoschmidt/8c83f972c20358a098a4 to your computer and use it in GitHub Desktop.
Save adrianoschmidt/8c83f972c20358a098a4 to your computer and use it in GitHub Desktop.
How to run a linux command in an Android app
try {
String commandLine = "date";
Process process = Runtime.getRuntime().exec(commandLine);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String value = bufferedReader.readLine();
TextView dateTextView = (TextView) findViewById(R.id.text_view_date);
dateTextView.setText(value);
} catch (IOException e) {
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment