Android设备执行Linux命令语句
2017-10-18 10:17
148 查看
用于Android设备执行Linux命令语句,更改root权限等
调用示例:
import java.io.*; 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){ } } Log.d("*** DEBUG ***", "ROOT SUC"); return true; }
调用示例:
//String apkRoot = "chmod 777" + getPackageCodePath();//获取整个apk权限
String apkChmod = "chmod 777 "+"/dev/video0"; RootCommand(apkChmod);
相关文章推荐
- Android执行SQlite语句时的问题备份
- Android启动另一个Activity时无法执行语句解决办法之加载延迟
- 在apk 中执行Runtime.getRuntime().exec adb shell各种命令远程控制其他Android设备(一)
- Ubuntu下执行Adb devices Android找不到设备
- Android之应用中执行Linux命令
- android 获取指定路径下所有文件,将文件从一个目录copy到另一个目录,执行linux命令
- 【Android设备管理】 利用DevicePolicyManager执行屏幕锁定
- 【Android笔记】执行命令行语句
- 【Android笔记】执行命令行语句
- android 程序执行linux命令注意事项
- Android应用中执行Linux命令
- 【Android设备管理】 利用DevicePolicyManager执行屏幕锁定
- 通过adb命令在Android设备中执行Java命令, 并调用so文件。
- android执行Linux命令
- android设备执行shell命令
- telnet登录android手机,可以执行部分linux命令
- Android学习杂记(三):在Android中使用Runtime执行Linux命令
- android执行Linux命令
- android手机(设备)横竖屏切换时activity的生命周期是如何执行的?