Android应用程序请求root权限

前提是手机已经破解获取root权限 只是简单的取得root权限: try { Runtime.getRuntime().exec("su"); } catch (Exception e) {} 取得root权限并在程序里获得root结果: private boolean hasRoot() { char[] arrayOfChar = new char[1024]; try { int j = new InputStreamReader(Runtime.getRuntime().exec("su -c ls") .getErrorStream()).read(arrayOfChar); if (j == -1) { return true; } } catch (IOException e) { } return false; } -c, ——commmand=COMMAND 执行一个命令,然后退出所切换到的用户环境; 执行"su -c ls"这样不会阻塞程序。

八月 30, 2012