If the device is installed on the root directory, you can use the following code to access the root shell:
try { Process process = Runtime.getRuntime().exec("su"); DataOutputStream outputStream = new DataOutputStream(process.getOutputStream()); DataInputStream inputStream = new DataInputStream(process.getInputStream()); outputStream.writeBytes(command + "\n"); outputStream.flush(); outputStream.writeBytes("exit\n"); outputStream.flush(); process.waitFor(); } catch (IOException e) { throw new Exception(e); } catch (InterruptedException e) { throw new Exception(e); }
Where "team" is the command you want to execute.
Blu dragon
source share