I'm using cordova-plugin-file-transfer and plugin cordova-plugin-file-opener2
I can get the apk to download but I keep on running into this error ever time:
Error status: 9 - Error message: Activity not found: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content://io.cordova.myappd06b01.opener.provider/external_files/Android/data/io.cordova.myappd06b01/files/someapp.apk typ=application/vnd.android.package-archive flg=0x40000000}
var targetPath = encodeURI(cordova.file.externalCacheDirectory + app_name);
var options = {};
var args = {
name: app_name,
url: event.url,
targetPath: targetPath,
options: options
};
downloadReceipt(args);
function downloadReceipt(args) {
var fileTransfer = new FileTransfer();
var uri = encodeURI(args.url);
fileTransfer.download(
uri,
args.targetPath,
function (entry) {
var pathToFile = cordova.file.externalCacheDirectory + args.name;
window.resolveLocalFileSystemURL(pathToFile, function (entry) {
cordova.plugins.fileOpener2.open(
entry.toURL(),
'application/vnd.android.package-archive', {
error: function (e) {
console.log('Error status: ' + e.status + ' - Error message: ' + e.message);
},
success: function () {
console.log('file opened successfully');
}
}
);
}, function (e) {
console.log('File Not Found');
});
},
function (error) {
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code" + error.code);
},
true,
args.options
);
}
var targetPath = encodeURI(cordova.file.externalCacheDirectory + app_name);
var options = {};
var args = {
name: app_name,
url: event.url,
targetPath: targetPath,
options: options
};
downloadReceipt(args);
function downloadReceipt(args) {
var fileTransfer = new FileTransfer();
var uri = encodeURI(args.url);
fileTransfer.download(
uri,
args.targetPath,
function (entry) {
var pathToFile = cordova.file.externalCacheDirectory + args.name;
window.resolveLocalFileSystemURL(pathToFile, function (entry) {
cordova.plugins.fileOpener2.open(
entry.toURL(),
'application/vnd.android.package-archive', {
error: function (e) {
console.log('Error status: ' + e.status + ' - Error message: ' + e.message);
},
success: function () {
console.log('file opened successfully');
}
}
);
}, function (e) {
console.log('File Not Found');
});
},
function (error) {
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code" + error.code);
},
true,
args.options
);
}