【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

感谢大家的推荐和收藏

你的支持! 我们的动力!

更多相关文章

  1. android 分隔线
  2. 动态添加TableRow
  3. 使用Vitamio打造自己的Android万能播放器(1)――准备
  4. 横竖屏切换 android:screenOrientation属性
  5. Android(安卓)studio使用笔记。。。
  6. android和js的相互调用
  7. Android之增强文本框(TextInputEditText)
  8. Android中VISIBLE、INVISIBLE、GONE的区别
  9. android 背景图片

随机推荐

  1. Android EditText 设置行距不影响光标高
  2. 优化技术之Android(安卓)UI优化
  3. android 面试题集
  4. Android Calendar使用过程中遇到的问题
  5. Android 中文 API (27) —— SeekBar.OnSee
  6. Android --- BaseAdapter
  7. [Android]在App中使用相机
  8. Android之adb环境变量配置
  9. android dialog 动画
  10. Android 如何开发 Bottom Navigation 风