`
aking86
  • 浏览: 81889 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

android应用程序中使用root权限

阅读更多

要在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;
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics