android手机是基于Linux内核开发的。在手机root后最大的好处就是开发者可以研究手机内部情况和开发自己喜欢的插件应用。
有时候在开发过程中会要求对手机核心文件进行访问或做其他操作,若没有现成的API接口就需要
靠用Linux指令来操作。下面的代码就是应用程序执行手机外部命令的方法:
public static int exce(String... strings) {
try {
Process process = Runtime.getRuntime().exec(strings);
int waitFor = process.waitFor(); return waitFor;
} catch (IOException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}