I am trying to create an intent that would open a pdf file on the web (a url) in a pdf reader. It seems to only work if the file is local.
I know this is going to depend on whether or not any of the installed apps can handle urls, but since I have several pdf readers installed (some of them claim they can read pdfs on the web) and none of them are responding I wanted to see if there was something wrong with my intent.
Here is what I am currently using:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(url), "application/pdf");
Thanks
To open a URL/website you do the following: String url = "http://www.example.com"; Intent i = new Intent(Intent. ACTION_VIEW); i.
Easy to use PDF viewer Fed up with having to download additional software to view a PDF file? Use DocFly to view PDF online so you can quickly read and edit your files. No software downloads required.
Opening a PDF file in Android using WebView All you need to do is just put WebView in your layout and load the desired URL by using the webView. loadUrl() function. Now, run the application on your mobile phone and the PDF will be displayed on the screen.
Build a url to the pdf using google docs viewer. This ends up loading much faster as they don't have to download the file in its entirety before you can display it.
private static final String googleDocsUrl = "http://docs.google.com/viewer?url=";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(googleDocsUrl + url), "text/html");
We recently did something similar except we used our own activity with an embedded webview to display the pdf rather than going to the browser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With