在java中可以用public static boolean RootCommand(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 ***", "ROOT REE" + e.getMessage());
return false;
} finally {
try {
if (os != null) {
os.close();
}
process.destroy();
} catch (Exception e) {
// nothing
}
} Log.d("*** DEBUG ***", "Root SUC ");
return true; }就可以以root权限来运行了。
但是c++中应该是什么写呢?c++中的system函数可以执行命令,但是不知道这么写是root权限运行。
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 ***", "ROOT REE" + e.getMessage());
return false;
} finally {
try {
if (os != null) {
os.close();
}
process.destroy();
} catch (Exception e) {
// nothing
}
} Log.d("*** DEBUG ***", "Root SUC ");
return true; }就可以以root权限来运行了。
但是c++中应该是什么写呢?c++中的system函数可以执行命令,但是不知道这么写是root权限运行。
解决方案 »
- 求助,ListView显示条目颜色动态设置问题。
- 菜鸟提问,怎么添加代码
- 询问一个关于空指针的问题和AVD模拟器横竖屏的问题
- 关于EditText?
- 【修改过问题】求tab+viewpage的解决方案,其中viewPage是嵌套在其中一个Fragment里面的?
- 编译android内核出现问题 隐式声明函数‘dmac_flush_range’未定义
- 谁有安卓socket传送图片
- 使用百度云推送,apk发布以后,出现NoClassDefFoundError
- 求助!!!Android数据更新后在listview上显示问题!!!
- Webview引起的崩溃,谁知道啊
- bootanimation 不流畅问题
- 求android平台网络收音机源码
system("su -c command");
system("sudo command");
system("sudo command");
能这样用吗?