Download files and/or display pdf through inAppBrowser - android

I successfully added the inAppBrowser Plugin to my Cordova (Ionic) app, but browsing through pages in the link I cannot download files or display PDFs, even though I can in other pages of my app (not in the iAB).
I tried to debug the plugin with adb, but i could not find anything.
Anyone has a solution for this?

I have had issues with the inAppBrowser and PDF's.
The current way I am doing it is by using a document viewer plugin: https://github.com/sitewaerts/cordova-plugin-document-viewer
It isn't ideal as it uses a 2nd app to display the PDF, but it's good enough for now. My aim is to eventually develop my own solution using PDF.js

Related

The easiest way to go from HTML5 app to Android APK

I've used Apache Cordova in the past, but I find it to be a headache. Spent a lot of time just to get it to compile correctly, almost more than developing the HTML5 app itself.
Is there some simple stand alone (offline) tool that takes a HTML5 project (HTML, CSS,JS, PNG, JPG files) and converts it to an APK with a simple press of a button?
Or is there some other way to piggy-back on some existing Android app, that just hosts a web browser, and then loads my HTML5 app?
Or is there a way to zip up the HTML5 project and distribute it as an app on an app store?
Or is there a way for the Android chrome browser to "appify" the current visited web page? The idea would be that the user presses a button to save down the current web page to the file system, and he can then access it offline as a regular app.
You can use Webview to show html files inside Android App. You can also show a particular website by giving its link. More Details here..
https://www.tutorialspoint.com/android/android_webview_layout.htm

Allow Phonegap's inappbrowser to access phone gallery?

Our app uses Phonegap's inappbrowser to point to our website. Our website (written in Laravel) has an edit profile page where you can upload a profile pic. This works fine on desktop but in the Phonegap app tapping the 'Choose Picture' button does not bring up the Android file system or gallery. I've installed both file system plugin and file transfer plugin for Cordova and it doesn't make a difference. Is my only choice really to re-write this part of the app custom for Phonegap using JS?
<input type="file" has a lot of know errors on mobile and isn't supported with Android WebViews in general. I would suggest using the FileTransfer Plugin to accomplish what you're trying to do. Use the upload method of this plugin to manually upload the file to the remote server. Also look at the Camera Plugin to choose which image on the device to upload.
Install the plugin cordova camera and also FileTransfer, I think that could help you much more than any kind of input, remembers working in the default browser and operating system often fail with different html attributes. There are several ways to get the picture from the device to make an upload to a server. If you're only working on Android, check your code on several devices since in some models (mostly Motorola) my fault I often a code if it works in Samsung for example. Always keep your updated plugins.
Plugin Camera
FileTransfer

Viewing a PDF file from HTML5 Hybrid Mobile App

Intending to view a PDF File from the Hybrid Mobile App , created using HTML5 Jquery and Packaged with Phonegap.
But unable to achieve it ,
Things i tried
<object src="xyz.pdf" type="application/pdf"></object>
also,
window.open('xyz.pdf'); //through javascript
and
$(document).load('xyz.pdf');
Can anyone suggest the best way for viewing the PDF in a Hybrid Android Mobile App.
with cordova you must think about these:
HTML 5 object tag: not working
If you try with:
window.open('http://www.???.com/my.pdf', '_blank', 'location=yes');
The InAppViewer canĀ“t open this kind of files.
I think that there aren't an hybrid solution for this problem.
You must start to search or write about a plugin that use a native pdf's opening and then use it.
An example:
cordova-plugin-file-opener
The latest solution, a little more simple but include to open google docs is:
window.open('https://docs.google.com/viewer? url=http://www.example.com/test.pdf&embedded=true', '_blank', 'location=yes');
ref = window.open('index.html', '_self');
Go look at the Mozilla pdfJS project.
This project allows you to open a pdf (embedded in app or remote) in your app. No break-out links that relies on native viewers.
They also give you a very full featured sample viewer, that you can use as is, but much of functionality in that does not apply to mobile applications.
I have had success with this on Android 4.3 Devices.
Try installing the InAppBrowser plugin to do so. I have use it to open PDF files right inside the app on both iOS and Android.
Check the official InAppBrowser doc with full doc and examples, it has several options you can enable/disable (be sure to point to your current cordova version documentation):
My solution for connected apps with offline availability...
window.open('http://www.someserver.com/doc.pdf', '_system')
...this will open in default pdf viewer. I have my clients use adobe reader for obvious reasons. And also because once it is downloaded the first time, adobe app manages and edits the documents well, and the documents are also available offline from within adobe reader thereafter. Even pdf forms.
Have cordova.js linked on the page.
Have inAppBrowser added.
For full offline you may try FileOpener plugin. I have not needed to do that on android, but I have used that way in iOS.
Hope any of this may help.
Though am late here, still want to share what I know. You can use this plugin to view PDFs in the app (without inappbrowser). Supports only Android and iOS.

How to use an PDF viewer in Flex mobile

I am developing a mobile application in Flex in Adobe Flash buillder 4.6 that will run on Android and iOS.
I need a way to view PDF files stored in the application storage directory. Searched in several forums and none of the suggestions worked for me.
In iOS'm using a StageWebView but Android still have not found a working solution.
Can be used ANE or not.
It needs to work offline, so I can not use google docs as a proxy.
Any suggestions?
I solved as was mentioned earlier.
Continued using webview in iOS and a ANE made a call to the Android application registered to open PDF.
Sorry for delay in giving feedback.
Thans for all

childbrowser on iPhone vs Android?

I use the childbrowser in my jqtouch - phonegap iPhone app and have now created it in Eclipse aswell, I have got the childbrowser to work in Android.
In the iPhone the childbrowser has a Done button and in the Android it opens a window with a address field at the top, is this how it suppose to look like - work?
When I open a .pdf or .doc document in the iPhone it opens in the childbrowser so I can read it, but in the Android it downloads the document, is this what it suppose to do?
If so, is there a way to open .pdfs so you can read it without downloading it first?
3. Is the childbrowser suppose to work in the emulator?
Thanks.
Yes, that's how it's supposed to work. The child browser is a bit non-idiomatic on the Android platform, since the Android way is generally more to open content that isn't native to the app on another app where it is (see question 2). The typical way in Android when you encounter a link is rather to open the web browser with that link, but in iOS the Child Brower UI pattern is very common. The Child Browser Android plugin also have a way of sending links to the web browser, I'd recommend you try it and consider using that instead of the Child Browser for your Android app version.
Also yes, that's also how Android generally works. Creating in-app viewers for .doc of .pdf -files would be too difficult if that's not the app's primary task.

Categories

Resources