Evolution-36 / cordova-plugin-file-opener2

Cordova plugin file opener based on pwlin's plugin. This plugin is updated to work with Android Oreo. This plugin was cloned because pwlin's plugin did not support writing access on Oreo.
MIT License
3 stars 4 forks source link

Error opening file Attempt to invoke virtual method #3

Open CarolineSan opened 4 years ago

CarolineSan commented 4 years ago

I getting the following error when trying to open a file:

Error opening file Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference

This is my code:

writeFile(base64:any, contentType: any, fileName: any) { 

    var DataBlob = this.base64toBlob(base64, contentType);  

    var filePath = this.file.externalRootDirectory + "download";

    this.file.writeFile(filePath, fileName, DataBlob, contentType).then((success) => {  

        this.fileOpener.open(success.toURL(), this.contentType)
            .then(() => console.log('File is opened'))
            .catch(e => console.log('Error opening file', e));

    }).catch((err) => {  
        console.log("Error Occured While Writing File", err);
    });  
  }

This is the URL that success.toURL() returns:

file:///storage/emulated/0/download/teste.pdf