Android website in webview, open file upload dialog - android

I have a webview that points to a website:
webView.loadUrl("https://websmash.herokuapp.com/");
When the user clicks on a file upload button in the website it should open a file upload dialog on the phone.
Matt Gaunt has provided a fully-functional example using onShowFileChooser(), although the file upload button is in the local index.html file. I've been trying to get this working for a website inside the webview, but to no avail.
What adaptations must be made to get it working when the button is in the website which the webview points to?

Take a look at this SO Post. Per the author`s answer code works for all android versions.

Related

Why do links to PDF documents now require https to work on Android phones?

We have a file server on which we place PDF documents and then embed links to them in a smart device app. Up until recently, using links to the PDF documents starting with http:// worked fine for Android and iPhone users. All could load the PDF file just fine. Then a few months back (approximately) Android phone users started reporting they would get an error when trying to load any PDF. Yet iPhone users had no issues loading the same PDF document. It was verified that these PDF documents (several) were not corrupted and opened fine when placed on another file server.
I have an iPhone so I can't give you the exact error msg received by Android users but to reproduce it, it was along the lines of... click the link to the PDF, a button appears showing View PDF, click that button and several apps appear to choose the app to open the PDF with, click one (like Adobe Reader, or Google Drive) and an error appears stating the file could not be opened and may be corrupted of the wrong syntax.
Tonight I found the solution.
The url to the PDF on all these documents on our server had been like http://...
but when I changed it to https://... it works fine.
I can't find ANYWHERE any mention of a change by Google that this is now a requirement.
My question...
Can someone explain and/or point me to a reference that explains why https must be used in embedded links to PDF documents? It seems like a pretty big deal to make this a requirement and not tell anyone. My searching the internet has so far not turned up anything.

Open Pdf link android

I have to show a PDF file inside my application and the PDF file contains a link inside (this link sends the user to the website).
I am searching for a library that allows me to show the file inside my application and if the user clicks the link, open a browser.
Is it possible?
Thanks in advance! :)
I personally use this one : AndroidPdfViewer
you can use a webview also following this example : Example pdf on webview

Android Webview with link new tab

Let's say I have an Android app that uses a webview. Inside that webview I have a link to download a PDF file like so:
<a href="LinkToDownloadPDF" target="_blank".../>
In a browser (Say Chrome for example), this will either download the file or opens it in a new tab.
My question is, what will happen once the webview is charged in the Android app? Will it download the file or open the web browser?
Nothing will happen when you download from webview without setting the download listener.
If you want to implement the feature of downloading something inside WebView, have a look at this question: Download File inside WebView

How to open pdf file with in our app android+phonegap+JQM?

I am developing an web+cross platform app using Jquery Mobile+PhoneGap+Android. In web app, I am able to open pdf file links within my app page using iframe. But, in Phonegap generated Android build, iframe is unable to render pdf content,it is showing that iframe area as empty.How can I display the pdf file/content, whose src I know at runtime, within android webview. Thanks In Advance.
I've just published my plugin, which can open almost any type of file, which is stored locally on Android device.
Please take a look at: https://github.com/markeeftb/FileOpener
Plugin opens external application which handles the preview of the document.

Open a pdf file inside a webview.

I have an app where I've button on a webpage that is rendered inside a webview.
Now on click of button , a pdf file gets downloaded , and the same would then need to be opened inside the same webview.
attach a download listener to the web view and change the url as follows..
"https://docs.google.com/gview?embedded=true&url=https://www.example.com/xxxxxyyyyyxz.pdf"
example
https://docs.google.com/gview?embedded=true&url=https://www.adobe.com/support/products/enterprise/knowledgecenter/media/c4611_sample_explain.pdf
it's a link used to open pdf without downloading it...
I hope it solves your problem..
I've found that the google viewer seems to work within the android browser for viewing online PDF files. You could build a link to your pdf so that it is displayed in the viewer. I've not tried doing that within a WebView though.
UPDATE
The link is dead, there is an explanation of how to get the functionality to still work at this link.
In case this link also dies, here is the relevant section:
While the page is no longer available as it redirects to Google Docs/Drive, you can still use the Google Docs Viewer. Paste this URL in a new tab:
https://docs.google.com/viewer?url=
and then paste the address of the document you want to view online. Here's an example:
https://docs.google.com/viewer?url=http://research.google.com/archive/bigtable-osdi06.pdf
I do not think that the present android chrome based browser can support pdf. There are discussion about the same in android forums ( ex: link1 link2)
Your best bet to show pdf is to have adobe pdf reader for android installed.(or concisely put, not possible in web view)
I don't think any browser other than Chrome supports rendering PDFs without a plugin or third party tool. It's probably easier to let the user use his own app to open PDFs.
I used the IText PDF library mentioned in this thread
Android : Is there any free PDF library for Android for a sample project. You could try getting using this API to get the PDF page as an image. I am not familiar with every aspect of Itext so it might have better way to do this.

Categories

Resources