即使应用程序在后台,我也需要在后台运行命令,但我没有找到任何办法。我是android开发的新手,所以......
public void RunAsRoot(String[] cmds) throws IOException {
Process p = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(p.getOutputStream());
for (String tmpCmd : cmds) {
os.writeBytes(tmpCmd + "\n");
}
os.writeBytes("exit\n");
os.flush();
}
RunAsRoot(anycommand);
public void onPause() {
super.onPause();
}