Android中用代码安装APK

1.先将APK文件保存到本地SDCard或其他地方;

2.修改apk文件的权限为可执行,例如name ‘commit’ file:

String command     = "name " + permission + " " + path;
Runtime runtime = Runtime.getRuntime();
runtime.exec(command);
3.使用Intent 调用安装:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(Uri.parse("file://" + path),"application/vnd.android.package-archive");
context.startActivity(intent);



你可能感兴趣的:(Android中用代码安装APK)