private static boolean hasRootPerssion() { PrintWriter PrintWriter = null; Process process = null; try { process = Runtime.getRuntime().exec("su"); PrintWriter = new PrintWriter(process.getOutputStream()); PrintWriter.flush(); PrintWriter.close(); int value = process.waitFor(); return returnResult(value); } catch (Exception e) { e.printStackTrace(); } finally { if (process != null) { process.destroy(); } } return false; } private static boolean returnResult(int value) { // 代表成功 if (value == 0) { return true; } else if (value == 1) { // 失败 return false; } else { // 未知情况 return false; } } }