现在的位置: 首页 > 综合 > 正文

获取root 权限

2014年01月08日 ⁄ 综合 ⁄ 共 861字 ⁄ 字号 评论关闭

 public static boolean 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 ***", "Unexpected error - Here is what I know: "+e.getMessage());

                    return false;
            }
            finally {
                    try {
                            if (os != null) {
                                    os.close();
                            }
                            process.destroy();
                    } catch (Exception e) {
                            // nothing
                    }
            }
            return true;
    }
}

 

 

 

 

抱歉!评论已关闭.