disusered / cordova-open

Open audio, video, images and more with applications installed on the user's device
MIT License
54 stars 55 forks source link

not able to open files in Android #37

Open simpixelated opened 9 years ago

simpixelated commented 9 years ago

Using version 10.4-1.0.9, I'm not able to open files on Android (5.0.1). It does trigger the intent screen, so I know that part is working. But after I select an app, it can't open the file. For PDFs I get a system message that says "Cannot display PDF (filename.pdf cannot be opened)". For images it opens in the app I chose but just shows a blank space or "Media not found.". Here's my code:

fileTransfer.download(fileModel.get('url'), localFilePath, function (entry) {
        window.cordova.plugins.disusered.open(entry.toURL(), success, error);
    }
}, error);

However when I call window.open with the same entry.toURL(), it does work, so I know the file exists and can be viewed. Here's an example URL: file:///data/data/com.homdna.HomDNA/files/appraisal.jpg. I've tried using fileOpener2 as well, with the same results. So I think it likely is a problem with Android, Cordova, or my own code.

tipstrade commented 9 years ago

I have the same issue - I'm assuming that it's a permission issue - the file is being downloaded to your app's data directory, which is not readable by other apps due to Android's sandboxing.

disusered commented 9 years ago

Yes this is typically due to permissions. I moved due to a family emergency and my time is fairly limited so I have not had a chance to dive into this, apologies.

On Mon, Oct 19, 2015 at 9:31 AM, TipsTrade Ltd. notifications@github.com wrote:

I have the same issue - I'm assuming that it's a permission issue - the file is being downloaded to your app's data directory, which is not readable by other apps due to Android's sandboxing.

— Reply to this email directly or view it on GitHub https://github.com/disusered/cordova-open/issues/37#issuecomment-149272289 .

Carlos

BudgieInWA commented 6 years ago

It should be possible to implement this on the native side using FileProvider as cordova-plugin-x-socialsharing does.