Last active
October 13, 2015 00:39
-
-
Save adrianoschmidt/8c83f972c20358a098a4 to your computer and use it in GitHub Desktop.
How to run a linux command in an Android app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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