Plugin combination of Cordova File, InAppBrowser, and File Opener

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.

Answer №1

Consider modifying this line

 var ref = cordova.InAppBrowser.open(fileEntry.toURL(), '_blank');

to

 var ref = cordova.InAppBrowser.open(fileEntry.toURL(), '_system');

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The radioGroup is duplicating my array every time I scroll between tabs on the setOnCheckedChangeListener event

Hey there! I'm facing a little problem that I could use some help with. I have a fragment containing two tabs (A and B). In tab A, there's a listview where each row displays a radioGroup with 5 radiobuttons. My goal is to capture the checked radi ...

Tips on improving image loading speed in JavaScript code

I'm working on a simple weather map that changes the background image depending on the current weather status. However, I've noticed that there is a delay in changing the image when the weather status changes. I'm wondering if this delay is ...

Enhanced efficiency in the interaction between front-end JavaScript and back-end JavaScript

As a frontend developer, I find myself in the unique position of working on a project that involves processing a large amount of data in my nodeJS backend (while using reactJS for the front end). After the necessary data processing is completed in the bac ...

What are the steps for integrating DoctorJS with Emacs?

Is there a method to utilize DoctorJS (formerly known as jsctags) in order to create a TAGS file specifically for Emacs? I have been researching this topic and it appears that it typically defaults to the vi tags style, although I may be overlooking a str ...

What data storage options provide synchronization for client data on both iOS and Android devices?

Many applications are currently creating custom logic for syncing and replicating cloud data or relying on platform-specific services like iCloud. Are there any cross-platform data synchronization solutions available besides creating your own from scratch ...

Expanding the size of the number input in Twitter Bootstrap to accommodate changing content dimensions

I have a numeric input field that I want to customize in terms of width. I need the field to start with a minimum width so that -1, the default value, fits nicely inside. As the value changes, whether decreasing to -100 or increasing to -1,000 and beyond ...

Android Progressbar with a sleek, borderless design

What is the best way to make a borderless progress bar? ...

Array containing HTML code for Ionic framework

Just starting out with Ionic/Angular and I have a question. How can I display an array containing HTML content? { "code" : "06", "descr" : "Some text:</br>Other text.<br/>Other text</br>Other text." } When I try to print it, the HTML ta ...

Error encountered in IONIC with SQLite: "Unable to access 'openDatabase' method"

Hello, I am a beginner with IONIC and I could use some assistance with using ngCordova. I have successfully created a database on my app.js file. However, whenever I try to access the database on my controller, I keep encountering this error message: "Type ...

Tips for adding an item to the top menu in an android application

I'm trying to add a new menu item to the top of my app (where the title class is located). I updated the menu.xml file and created an Intent to launch a new class when the item is clicked. However, now the entire app doesn't open anymore. Removin ...

The message appearing on my screen reads: "Attempting to read properties of an undefined value, specifically 'map'."

I am attempting to create a map of my various people, but I keep encountering an error with the title. I'm having trouble understanding where the issue lies, here is my code snippet: export const Testt = ({ childs}) => { console.log(childs) ...

What are the steps to accessing validation errors using express-validator?

Recently, I delved into the world of express-validator to enhance my skills. Despite going through the documentation thoroughly, there's a query lingering in my mind that might have already been addressed in the docs. My confusion arises from needing ...

Is there a way I can ensure that my buttons shrink as the screen size changes?

After generating buttons using my JavaScript code based on contents from a JSON file, I utilized a display grid structure to arrange them with a maximum of 2 buttons per row. However, there seems to be a styling issue as the larger buttons overflow off the ...

Malfunctioning JavaScript timepiece

I am currently experimenting with using Raphael to create a unique clock feature on my website. My goal is to animate the seconds hand to mimic the movement of a traditional clock. Below is the code snippet I have implemented: window.onload = function( ...

Tips on inserting a drawable line to divide content into two columns

I have created an XML file below, and I am currently experiencing issues with the borders. The borders are appearing on the outer side and between the rows. However, I am struggling to add a border that divides a row into two columns, similar to dividing t ...

Is the required attribute for form submission in Material UI not verifying in another file?

It seems that I may be importing incorrectly because a required field does not display a "please fill in this field" popover when attempting to submit a form. The imported classes are as follows: import * as React from 'react' import FormContro ...

Having difficulties updating the appwidget due to problems with sqlite

I'm encountering a problem with updating my appwidget. It's a simple widget that uses a service to update the widget and retrieve quotes from a SQLite database, then display them on the homescreen. In the log, I can see that the quotes were inse ...

Validating the existence of a file through HTTPS in Javascript

After attempting to retrieve the file using this code, I've encountered an issue - it works with HTTP requests but not HTTPS requests (which is what I require). function checkUrl(url) { var request = new XMLHttpRequest(); try { request.ope ...

The transition from material-ui v3 to v4 results in a redux form Field component error stating 'invalid prop component.'

Since upgrading from material-ui v3 to v4, I am encountering an error with all my <Field> components that have the component prop. Error: Warning: Failed prop type: Invalid prop component supplied to Field. The Field component is imported from im ...

- "Utilizing the _underscore loop within a design framework"

I am encountering a persistent error while working on this. Specifically, I keep receiving an error related to syntax: syntax error var _p=[],print=function(){_p.push.a... ');}return __p.join(''); <script id="product" type="text/t ...