启动安装 最好使用下面 更保险
intent.setDataAndType(uri, "application/vnd.android.package-archive");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
List<ResolveInfo> resInfoList = mContext.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
for (ResolveInfo resolveInfo : resInfoList) {
Log.e("update", resolveInfo.activityInfo.packageName);
String packageName = resolveInfo.activityInfo.packageName;
mContext.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
}
}
mContext.startActivity(intent);
网友评论