Fix issue with new Android to install apk

This commit is contained in:
Victor Shcherb 2020-01-07 17:39:24 +01:00
parent 22346fbf81
commit 8b0622a592

View file

@ -112,17 +112,17 @@ public class ContributionVersionActivity extends OsmandListActivity {
} }
} else if(operationId == INSTALL_BUILD){ } else if(operationId == INSTALL_BUILD){
if(currentSelectedBuild != null){ if(currentSelectedBuild != null){
Intent intent;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Uri apkUri = FileProvider.getUriForFile(this, getPackageName() + ".fileprovider", pathToDownload); Uri apkUri = FileProvider.getUriForFile(this, getPackageName() + ".fileprovider", pathToDownload);
Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE); intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
intent.setData(apkUri); intent.setData(apkUri);
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
} else { } else {
Intent intent = new Intent(Intent.ACTION_VIEW); intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(pathToDownload), "application/vnd.android.package-archive"); intent.setDataAndType(Uri.fromFile(pathToDownload), "application/vnd.android.package-archive");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivityForResult(intent, ACTIVITY_TO_INSTALL);
} }
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivityForResult(intent, ACTIVITY_TO_INSTALL);
updateInstalledApp(false, currentSelectedBuild.date); updateInstalledApp(false, currentSelectedBuild.date);
} }
} }