I have a webview in my app and I got it working like this
webview = (WebView) findViewById(R.id.mainWebView);
webview.loadUrl("https://www.google.com");
But if I try to load the non mobile version of the https://uniondining.sodexomyway.com/Images/MAR2015dutchCalendar_000_tcm1792-59025.pdf it exits out of the app.
How can I load the mobile version of site in my app?
Thanks
Unfortunately, Android does not support viewing PDFs out of the box in a WebView. Luckily, Google has a nifty little tool that allows you to perform this very task quite easily using Google Docs. Basically we will embed our PDF in a Google Doc page on-the-fly and load that.
You can use Google Docs Viewer to read your pdf online:
Here's the code:
WebView webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
String pdf = "http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf";
webview.loadUrl("http://docs.google.com/gview?embedded=true&url=" + pdf);
If you use the view only url the user is not propted to login to there google account.
You're trying to open a link to PDF file. While desktop browsers like Chrome can open it, Android WebView has no builtin PDF reading possibility, so you can't show this inside the WebView. Instead, you can try to download the file and open it with some PDF library like MuPDF.
Also, you need to check if you have permission android.permission.INTERNET set up in your AndroidManifest.xml
Check your URL again. You are trying to loead a pdf which webView can't load but desktop browsers like IE and chrome. But in case of android WebView cant load PDF files.
You can use android pdf library also to create your pdf viewer otherwise you can display it using any pdf viewer installed on your mobile.
Related
I'm trying to uplaod html link url to Android Webview.
But I've noticed that it is differ by Android device and OS version.
In Some Device shows the whole texts while the other does not show all the texts.
Is there any way to show whole texts Programmatically.
I'm using Java language and the code is Just
this.loadUrl(strHtml);// this load www.blahblah.com/blah.html
Thank you.
I am using webview to create an Android app that navigates to my website but some of the content of the website is in flash. Is there anyway to make webview show flash videos?
I have tried adding the line myWebView.getSettings().setMediaPlaybackRequiresUserGesture(true); to my MainActivity.java , and adding android:hardwareAccelerated="true" to my AndroidManifest.xml file.
I was expecting to have my app with webview to play flash videos.
Can't be done. Adobe Flash Player hasn't been supported on Android since version 11.1.
I am loading facebook in my webview in android studio,but I cant select the text of posts or comments,while if I load another website I can do that .Anyone knows how to enable that ?
Selecting Text on mobile version of Facebook doesn't work in Chrome too. Try to disable Javascript in your webview.
I'm using web-view in an android application. In that application I have to view attached PDF and images. When I click image file it's opening fine, but when I click PDFs it's not opening.
As said you need to use a native pdf renderer like RadaeePDF SDK for example, or you can try (https://mozilla.github.io/pdf.js/) inside the webview.
Rendering using JS should work well on the webview of the versions 4.4 and 5.x, For earlier versions you can check Show PDF file in Android WebView using mozilla pdf.js Android API Level below 19
How can I get the full path of flash player lite,
and use it to play my target .swf ?
Honestly, I don't know if you can call flash player from outside a browser. What you can do is, create an activity containing a WebView, embed the .swf into a HTML webpage, load that page in the webview, and you should have a working flash thingy. HTML is easy to style using CSS and javascript, in case you want buttons on the same page etc. You won't however be able to achieve a true native look and view. With HTML5 you can get quite close though.
Should you really want that "native" looking application, you can extract the images that android OS uses and style your page to android style. If the version number changes(for example, android uses new native look and feel), your page wont automagically adjust it's style though.
Refer to this link on how to load local html files into a webview.