清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
1.支持静默安装的机器必须Root,这个不需要我多讲了。
2.使用pm指令安装即可。
3.特别注意 PM指令不支持中文,也就说路径中有中文会导致安装失败!
关键代码如下:
public int execRootCmdSilent(String cmd) {
int result = -1;
DataOutputStream dos = null;
try {
Process p = Runtime.getRuntime().exec("su");
dos = new DataOutputStream(p.getOutputStream());
Log.i(TAG, cmd);
dos.writeBytes(cmd + "\n");
dos.flush();
dos.writeBytes("exit\n");
dos.flush();
p.waitFor();
result = p.exitValue();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (dos != null) {
try {
dos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return result;
} 不需要在Manifest中声明任何权限