申请root的工具类

//获取root权限
RootManager manager=new RootManager();
manager.upgradeRootPermission(getPackageCodePath());
public class RootManager {

    /**
* 应用程序运行命令获取 Root权限,设备必须已破解(获得ROOT权限)
*
* @return 应用程序是/否获取Root权限
*/
public boolean upgradeRootPermission(String pkgCodePath) {
Process process = null;
DataOutputStream os = null;
try {
String cmd="chmod 777 " + pkgCodePath;
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) {
}
}
return true;
} }

最新文章

  1. html规范
  2. COOKIE和SESSION关系和区别
  3. Crawler & Ajax:WebBrowser C#
  4. 3、HelloKhala示例说明
  5. #include <sstream>
  6. iOS 学习资料汇总
  7. promise/bluebird源码
  8. Python爬虫(十二)_XPath与lxml类库
  9. python3.6 使用 pymysql 连接 Mysql 数据库及 简单的增删改查操作
  10. Shell脚本中获取select值
  11. 深入了解EntityFramework Core 2.1延迟加载(Lazy Loading)
  12. hive的join
  13. PHP获取站点根目录
  14. Swift中的Any 与 AnyObject、AnyClass的区别?
  15. 统计词语频率保存到xls
  16. 20145319 《网络渗透》DNS欺骗
  17. c# winform 中DataGridView绑定List<T> 不能显示数据
  18. origin里用c语言编程
  19. BETA-1
  20. NO.11天作业

热门文章

  1. "Your computer could not be joined to the domain. You have exceeded the maximum number of computer accounts you are allowed to create in this domain. Contact your system administrator to have this limit reset or increased."
  2. Key Vertex (hdu 3313 SPFA+DFS 求起点到终点路径上的割点)
  3. 基于CRF的中文分词
  4. nginx location 匹配的规则
  5. WordPress 获取指定分类ID的分类信息
  6. Eclipse Maven项目报错2之A child container failed during start
  7. String escape/unescape into XML
  8. mysql 批量数据循环插入
  9. windows server 2012 st 版本的php环境问题修复 与删除
  10. Android 多语言支持