I am experiencing an issue with opening a PDF file that I have stored using the File Plugin. I have tried using both the InAppBrowser and File Opener Plugin, but neither seem to work. I am currently using the Visual Studio Emulator KitKat for Android.
When using the InAppBrowser Plugin, the fileEntry.toURL()
method returns "file:///data/data/com.ionicframework.ionicblankapp/cache/Sample.pdf". However, the InAppBrowser always displays a blank page.
window.resolveLocalFileSystemURL(cordova.file.externalDataDirectory, function (dirEntry) {
dirEntry.getFile(fileName, { create: true, exclusive: false },
function (fileEntry) {
fileEntry.createWriter(
function (fileWriter) {
fileWriter.onwriteend = function (e) {
var ref = cordova.InAppBrowser.open(fileEntry.toURL(), '_blank');
};
fileWriter.write(fileBlob);
});
});
});
As for the File Opener Plugin, I am receiving an error status of "9" with the following message:
Activity not found: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///data/data/com.ionicframework.ionicblankapp/cache/Sample.pdf typ=application/pdf flg=0x4000000 }"
Below is the code snippet for the File Opener Plugin:
window.resolveLocalFileSystemURL(cordova.file.externalDataDirectory, function (dirEntry) {
dirEntry.getFile(fileName, { create: true, exclusive: false },
function (fileEntry) {
fileEntry.createWriter(
function (fileWriter) {
fileWriter.onwriteend = function (e) {
cordova.plugins.fileOpener2.open(fileEntry.toURL(), 'application/pdf', {
success: function () {
//success
},
error: function (e) {
alert(e);
});
};
fileWriter.write(fileBlob);
});
});
});
I am currently unsure of what I may be missing. Any assistance would be greatly appreciated.