Android用代码安装APK,不用选择“打包安装程序”

来源:互联网 发布:吉利知豆d3 编辑:程序博客网 时间:2024/05/01 01:41
public static boolean InstallPkgByFile(Context context, String strFilePath,String strFileName) {File file = new File(strFilePath + File.separator + strFileName);if (file.exists()) {Intent intent = new Intent(Intent.ACTION_VIEW);//关键就是这儿了intent.setDataAndType(Uri.fromFile(file),"application/vnd.android.package-archive");context.startActivity(intent);return true;} else {return false;}}