Android 获取系统权限的代码

public static boolean runRootCommand(String command) {        Process process = null;        DataOutputStream os = null;            try {            process = Runtime.getRuntime().exec("su");            os = new DataOutputStream(process.getOutputStream());            os.writeBytes(command+"\n");            os.writeBytes("exit\n");            os.flush();            process.waitFor();            } catch (Exception e) {                    Log.d("*** DEBUG ***", "Unexpected error - Here is what I know: "+e.getMessage());                    return false;            }            finally {                    try {                            if (os != null) {                                    os.close();                            }                            process.destroy();                    } catch (Exception e) {                            // nothing                    }            }            return true;    }} 


更多相关文章

  1. 编译代码报出Android library projects cannot be launched错误
  2. 解决Eclipse3.6中Android 代码自动补全卡死的问题
  3. (安卓权限)Android Permissions
  4. android 下测试网络的丢包率和延迟 的代码
  5. 《Android/OPhone 开发完全讲义》已出版,现提供源代码下载
  6. 如何关联androidSDK源代码
  7. Unity2019通过unity获取Android动态权限(不用在Android写插件)

随机推荐

  1. Android(常用)主流UI开源库整理
  2. Android(安卓)RIL Java
  3. 闲聊 Android 异步任务
  4. Android任务、进程、线程的关系
  5. android box2d重力系统 碰撞检查(二)
  6. [置顶] android中图片的三级cache策略(内
  7. [置顶] Android面试必须要知道的事情
  8. 彻底理解Android中的ThreadLocal
  9. Android 功耗优化(4)---android 7.0低电耗D
  10. Android 开发之短信的收发及在android模