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.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.content.FileProvider;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -16,6 +18,7 @@ import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.osm.io.NetworkUtils;
|
import net.osmand.osm.io.NetworkUtils;
|
||||||
|
import net.osmand.plus.BuildConfig;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.Version;
|
import net.osmand.plus.Version;
|
||||||
|
|
||||||
|
@ -109,11 +112,18 @@ public class ContributionVersionActivity extends OsmandListActivity {
|
||||||
}
|
}
|
||||||
} else if(operationId == INSTALL_BUILD){
|
} else if(operationId == INSTALL_BUILD){
|
||||||
if(currentSelectedBuild != null){
|
if(currentSelectedBuild != null){
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
Uri apkUri = FileProvider.getUriForFile(this, getPackageName() + ".fileprovider", pathToDownload);
|
||||||
intent.setDataAndType(Uri.fromFile(pathToDownload), "application/vnd.android.package-archive");
|
Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
|
||||||
startActivityForResult(intent, ACTIVITY_TO_INSTALL);
|
intent.setData(apkUri);
|
||||||
updateInstalledApp(false, currentSelectedBuild.date);
|
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
} else {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
|
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