要在android应用程序中使用root权限,那么运行程序的设备必须具有root权限。

http://www.eoeandroid.com/code/2012/0320/973.html

写道 public static boolean runRootCommand(String command) {
String TAG = "";
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(TAG,
"the device is not rooted, error message: "
+ e.getMessage());
return false;
} finally {
try {
if (os != null) {
os.close();
}
if (process != null) {
process.destroy();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return true;
}

更多相关文章

  1. Dojo mobile TweetView 系列教程之五 —— TweetView: Android,打
  2. Android应用程序启动时发生AndroidRuntime : ClassNotFoundExcep
  3. 什么是Android?
  4. Android(安卓)初步
  5. android中跳转系统自带界面
  6. 【API Guides视频系列】第1篇Application Fundamentals(应用程序
  7. 2011.09.07(4)——— android 跨进程通信之content provider
  8. android保持屏幕常亮
  9. Android应用程序的内存泄漏问题

随机推荐

  1. Android 2.3文档学习
  2. Android屏蔽home键的代码,咋摁也不响应的
  3. Android Dialog顶部显示+横向全屏+沉浸式
  4. android 利用Gson生成json数据
  5. Android cts测试命令
  6. tabhost相关报错
  7. android notification 事件
  8. Retrofit2在Android的使用
  9. Android:使用HttpClient接口实现网络通信
  10. 在Android中使用Lombok减少编码