Fix issue with new Android to install apk
This commit is contained in:
parent
a8070e7a88
commit
22346fbf81
1 changed files with 15 additions and 5 deletions
|
@ -4,7 +4,9 @@ import android.app.ProgressDialog;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.FileProvider;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -16,6 +18,7 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.osm.io.NetworkUtils;
|
||||
import net.osmand.plus.BuildConfig;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
|
||||
|
@ -109,10 +112,17 @@ public class ContributionVersionActivity extends OsmandListActivity {
|
|||
}
|
||||
} else if(operationId == INSTALL_BUILD){
|
||||
if(currentSelectedBuild != null){
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
Uri apkUri = FileProvider.getUriForFile(this, getPackageName() + ".fileprovider", pathToDownload);
|
||||
Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
|
||||
intent.setData(apkUri);
|
||||
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
} else {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
intent.setDataAndType(Uri.fromFile(pathToDownload), "application/vnd.android.package-archive");
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
startActivityForResult(intent, ACTIVITY_TO_INSTALL);
|
||||
}
|
||||
updateInstalledApp(false, currentSelectedBuild.date);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue