【Android】Android 代码判断是否获取ROOT权限(一)

【Android】Android 代码判断是否获取ROOT权限

方法比较简单,直接粘贴代码

 

public synchronized boolean getRootAhth()
    {
        Process process = null;
        DataOutputStream os = null;
        try
        {
            process = Runtime.getRuntime().exec("su");
            os = new DataOutputStream(process.getOutputStream());
            os.writeBytes("exit\n");
            os.flush();
            int exitValue = process.waitFor();
            if (exitValue == 0)
            {
                return true;
            } else
            {
                return false;
            }
        } 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)
            {
                e.printStackTrace();
            }
        }
    }

 

本文出自 Ray-Ray的博客

文章地址 http://www.cnblogs.com/rayray/p/3183677.html 

感谢大家的推荐和收藏

你的支持! 我们的动力!

posted @ 2013-07-11 12:00  Rex..  阅读(8850)  评论(0编辑  收藏  举报