我正在以编程方式安装APK并使用以下代码:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Uri apkUri = FileProvider.getUriForFile(getApplicationContext(),
BuildConfig.APPLICATION_ID + ".fileprovider", new File(Environment
.getExternalStorageDirectory() + "/.QCApp/" +
Constants.APP_TYPE + versionName + ".apk"));
Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
intent.setData(apkUri);
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(intent);
} else {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() +
"/.QCApp/" +
Constants.APP_TYPE + versionName + ".apk")),
"application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
但是在Android Nougat APK中成功安装但是" Done"和"打开"屏幕没有出现。 我错过了什么?