您的位置:首页 > 其它

获取root 权限

2011-11-04 18:37 267 查看
 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;

    }

}

 

 

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息