Closed imgx64 closed 6 years ago
I'm going in an endless loop when opening a PDF. Nothing happens except getting thousands of these in the logs:
10-24 06:18:23.706 3210-3273/com.company.app D/EGL_emulation: eglMakeCurrent: 0xae8e8b80: ver 2 0
Tested on 5.1 (API 22)
@boboldehampsink Where is the PDF file located? And do you have a default application that opens PDF or are you getting the "Open with..." page?
The PDF is located in the cache directory. It's not opening at all (no open with and no default application). This might be due to not having any capable pdf app installed at all.
How are you calling it? This code works on my Android 5.0 device:
function log(a) {console.log(a);};
resolveLocalFileSystemURL(cordova.file.cacheDirectory, function(directory) {
directory.getFile('test.pdf', {}, function(file) {
cordova.plugins.fileOpener2.open(
file.toURL(),
'application/pdf',
{
success: log,
error: log,
}
);
}, log);
}, log);
Okay, tested on simulator with 5.1 without pdf apps didn't work, but so didn't the original version. Tested on a real device with 5.0 works, but I don't see any difference with the original version.
I don't see any difference with the original version.
Well, the sample code I posted above does not work on Android <6 when using version 2.0.19 of this plugin (the PDF app starts, but it can't read the file). With this PR, it works correctly.
If there's no app to open PDF, the error
callback is called and you can ask the user to install a PDF app.
Ok, I can confirm that opening a file on < 6.0 does not work in the original code, and works with this code. Thanks for this.
Guys how can i use this fix on my app?
cordova plugin add https://github.com/imgx64/cordova-plugin-file-opener2.git
Thank you,this PR works on Android 5.1.1, 6.0.1, 7.1.1 (real devices)
Thank you very much for your contributions.
Various Android fixes. To verify it doesn't break anything, I tested opening a PDF and installing an APK on Android 4.1, 4.4, 5.0, 6.0, and 7.0.