/**
* 判断当前手机是否有ROOT权限
* @return
*/
public boolean isRoot(){
boolean bool = false;
try{
if ((!new File("/system/bin/su").exists()) && (!new File("/system/xbin/su").exists())){
bool = false;
} else {
bool = true;
}
Log.d(TAG, "bool = " + bool);
} catch (Exception e) {
}
return bool;
}
复制代码
调用的代码,大家好好看看吧
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//当前应用的代码执行目录
upgradeRootPermission(getPackageCodePath());
}
复制代码
执行上述代码后,系统会弹出对话框“是否允许获取Root权限”,此时选择允许即可。
取消
评论