where the request code > 0, standard mode, 7.0 (real machine), 8.0 (virtual machine) can.
private void installApp() {
Intent intent = new Intent(Intent.ACTION_VIEW);
File file = new File(appTask.path);
textAppProgressStatus.setText("");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Uri contentUri = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".fileProvider", file);
intent.setDataAndType(contentUri, "application/vnd.android.package-archive");
} else {
// FIXME: 2018/8/2 Android 4.4 API 19 startActivityForResult onActivityResult
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
Log.d(TAG, "installApp: ");
startActivityForResult(intent, REQUEST_CODE_INSTALL);
}