Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- httpModule.getFile( url, destFilePath ).then(
- function( result: fileModule.File )
- {
- let destFile = fileModule.File.fromPath( result.path );
- let file = new java.io.File(destFile.path);
- let context = application.android.context;
- let shareableFileUri;
- let sdkVersionInt = parseInt(platformModule.device.sdkVersion);
- let intent;
- if (sdkVersionInt >= 24) // Nougat 7.0
- {
- shareableFileUri = android.support.v4.content.FileProvider.getUriForFile(context, application.android.nativeApp.getPackageName() + ".provider", file);
- intent = new android.content.Intent( android.content.Intent.ACTION_INSTALL_PACKAGE );
- intent.setDataAndType( shareableFileUri, "application/vnd.android.package-archive" );
- intent.setFlags( android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION|android.content.Intent.FLAG_ACTIVITY_NEW_TASK );
- }
- else
- {
- // not testing this version
- }
- application.android.foregroundActivity.startActivity( intent );
- } ).catch( (reason) =>
- {
- console.error( "_downloadAndInstallApkFile " + reason );
- } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement