android应用程序中使用root权限
16lz
2021-12-04
要在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;
}
更多相关文章
- Dojo mobile TweetView 系列教程之五 —— TweetView: Android,打
- Android应用程序启动时发生AndroidRuntime : ClassNotFoundExcep
- 什么是Android?
- Android(安卓)初步
- android中跳转系统自带界面
- 【API Guides视频系列】第1篇Application Fundamentals(应用程序
- 2011.09.07(4)——— android 跨进程通信之content provider
- android保持屏幕常亮
- Android应用程序的内存泄漏问题