android运行root命令

来源:互联网 发布:阿里云api怎么使用教程 编辑:程序博客网 时间:2024/06/11 00:21
public static void runRootCommand(String command) {        Process process = null;        DataOutputStream os = null;        try {            process = Runtime.getRuntime().exec("su");            os = new DataOutputStream(process.getOutputStream());            os.writeBytes(command + "\n");            os.writeBytes("exit\n");            os.flush();            process.waitFor();        } catch (Exception e) {            Log.d("*** DEBUG ***", "ROOT REE" + e.getMessage());        } finally {            try {                if (os != null) {                    os.close();                }                process.destroy();            } catch (Exception e) {            }        }    }
0 0