Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.