网上查到的方法
Process process = null; DataOutputStream os = null; try { String cmd = "chmod 777 " + getPackageCodePath(); process = Runtime.getRuntime().exec("su"); // 切换到root帐号 os = new DataOutputStream(process.getOutputStream()); os.writeBytes(cmd + "\n"); os.writeBytes("exit\n"); os.flush(); process.waitFor(); } catch (Exception e) { // return false; } finally { try { if (os != null) { os.close(); } process.destroy(); } catch (Exception e) { } }但是好像仅限于cmd的那句命令有root权限
后来又查到
Process process = Runtime.getRuntime().exec("su");“执行这一句,superuser.apk就会弹出授权对话框。
但是这样做就可以了吗.....肯定没这么简单啦!
当执行需要系统权限的操作时,系统还是回去检查应用程序是否拥有该权限。
所以我们要想办法绕过过系统检查权限这道关卡!”
之后就不了解了。希望在以后的学习中能够了解这方面的知识!