android check root

来源:互联网 发布:巴伐利亚级战列舰知乎 编辑:程序博客网 时间:2024/05/17 03:54
<span style="white-space:pre"></span>/** * 判断设备是否Root *  * @return */public static boolean checkRoot() {try {Process process = Runtime.getRuntime().exec("/system/bin/ls -l /system/bin/su /system/xbin/su");BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));String line = reader.readLine();reader.close();process.destroy();return (line != null && line.length() > 9)&& (line.charAt(9) == 'x' || line.charAt(9) == 't');} catch (Exception e) {return false;}
0 0
原创粉丝点击