try{
Process process;
process = Runtime.getRuntime().exec(command);
BufferedReader in = new BufferedReader(new
InputStreamReader(process.getInputStream()));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
It depends on the command you wish to run, you may not need any. However, if your attempting to run a system level command you will need root access (not an Android permission). Running a platform command pretty much circumvents anything going on with Android permissions and is only affected by whether or not your linux user id has read/write/execute permission for the command you are issuing.
Runtime.exec() will also throw a SecurityException if you are not allowed to run a specific command and the exception will provide more details as to why in the specific case, so you should probably catch that in your try block also. You may also use Runtime.checkexec() to verify if you can run a certain command string before you actually attempt it.
Hope that Helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With