标签:
应用宝、360应用、豌豆荚等等都有一个比较好的功能就是下载应用自行安装,不用弹出安装应用对话框,他是怎么做到的呢?
这边采用在应用内部使用shell实现,但前提必须root,代码很简单:
public static void InstallAPK(String filename){
File file = new File(filename);
if(file.exists()){
try {
String command;
command = "pm install -r " + filename;
Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", command });
proc.waitFor();
} catch (Exception e) {
e.printStackTrace();
}
}
}InstallAPK("/sdcard/JustTest.apk");
大功告成。
标签:
原文地址:http://blog.csdn.net/huiguixian/article/details/42970997