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();}}}




方法二:

//判断机器 Android是否已经root,即是否获取root权限  protected static boolean haveRoot()  {    int i = execRootCmdSilent("echo test"); //通过执行测试命令来检测    if (i != -1)  return true;    retrun false;  }

更多相关文章

  1. 【总结备用】Android(安卓)获取正在运行的任务和服务
  2. android 中调用系统的发短信功能
  3. Android(安卓)使用正则表达式
  4. android 权限库,拿来就能用
  5. 如何查看Android设备的CPU架构信息
  6. android location 位置定位
  7. Android(安卓)Drawable、Bitmap、byte[]之间的转换
  8. View的XML 属性大全(官方文档)
  9. 判断Android客户端网络是否连接

随机推荐

  1. android导入第三方包(解决ClassNotFound错
  2. Android的蓝牙实例代码中找不到REQUEST_E
  3. [Android NDK]Android JNI开发例子 ---2
  4. 【Android】进入应用和切换界面时闪屏的
  5. 总结Android中的Info系列类
  6. Android简单模糊背景和圆形ImageView
  7. android studio GC overhead limit excee
  8. Android自定义Toast样式和时间
  9. Android初学路上会遇到的瓶颈
  10. Android(安卓)viewpager里面嵌套使用list