My application has a list of pdf inside listview. The pdf is viewed inside the application using a webview that open a Google Docs sheet. It works fine for the first opened PDF, but
when going back and opening another PDF I got the error "whoops! There was a problem previewing this document". Is there some kind of limitation on opening PDF using google sheet. If so, how can I get full rights to open any PDF I want. can someone help please. Here is my code.
//---you need this to prevent the webview from
// launching another browser when a url
// redirection occurs---
wv.setWebViewClient(new Callback());
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setAllowFileAccess(true);
wv.loadUrl("https://docs.google.com/gview?embedded=true&url=" + SharepreferenceController.getPrefSavePdfInfo());
Try increasing the Version/Compatibility of the PDF. This worked for me.
Edit: I believe it is more of a size issue. When I changed the Version (from Acrobat 9.0 to 10.0) I had also optimized the PDF making it a smaller file. My larger files of the same Version still do not work.
I was having the same issue. What solved it for me was clearing the WebView cache before trying to load another PDF.
WebView webView=(WebView)findViewById(R.id.webView);
webView.clearCache(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("https://docs.google.com/viewer?url=" + url);
Related
I am trying to load a HTML page which will have an option to choose the .dae file(3d model) using file explorer and it should be loaded in webview. This is working fine in chrome browser but not in webview.
I have enabled the below settings.
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setAllowContentAccess(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDomStorageEnabled(true);
I am able to choose the .dae file and after that nothing happens. Whereas it's loading the 3D model in chrome browser of the device.
Can someone help me on this? Do I need to enable any other settings? Thanks in advance.
Mobile webview is not the Movile browser, they have different render ability.
WebView is render ability cannot match the browser.
To sove this, use XWalkView of crosswalk to replace webview.
How to use crosswalk to render 3D models refer to my answer here.
I want to view favicon.ico in the browser but not download them to my computer. How do I enforce that?
punch line
I have an app that is supposed to display favicons given a url. The app is successful only when the favicon.ico would display in browser as opposed to downloading. So I need to somehow force the image to display in browser. For example http://www.nydailynews.com/favicon.ico does not display in browser but rather downloads (chrome browser). But I see that safari is able to force it to display in browser. How can my android app do the same, as safari?
From android I am using picasso to load the images in a ListView
This is not a solution, but I'm not really sure what you're trying to do. Favicon does load in the WebView, it doesn't download it. I just tried the following code,
WebView view = (WebView) findViewById(R.id.web_view);
view.loadUrl("http://www.google.com/favicon.ico");
And this loads the icon in the WebView. Also I tried opening the same url in my Chrome Android app and it works too. It doesn't download it.
P.S. Note that I'm testing on Motorola Moto X running Android 5.1.
Update
Try this
WebView webView = (WebView) findViewById(R.id.web_view);
String data = "<body>" + "<img src=\"http://www.nydailynews.com/favicon.ico\"/></body>";
webView.loadData(data, "text/html", "utf-8");
i want to view pdf file from internet..can anyone tell me how can i view??
Please Use This code For view Online PDF without Using PDF of Application
mWebView.loadUrl("http://docs.google.com/gview?embedded=true&url=http://your_link/634128127095123576.pdf");
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);
Please view this answer for more details: how to develop a pdf reader in android
But please be aware that webview does create some extra threads like Cookie Manager and history manager , it might just increase your memory foot print a bit. I saw this behaviour when i looked at threads created in Eclipse ADT plugin
I want to display swf into a webview. The swf didn't display in the web view. I have this message fail(the browser should render some flash content, not this).
So I try this code. But I am getting ,swf file in encoded form in webview.
What to do to display this swf??
String url ="file:///android_asset/hoge.swf";
WebView wv=(WebView) findViewById(R.id.WebView01);
wv.getSettings().setPluginsEnabled(true);
wv.loadUrl(url);
swf is a flash file.
to be able to display flash file, the device should be supporting flash. recently, there's many android device not support flash. so you must be careful. also check whether the device is already installed flash plugin or not.
Lots of questions have been posted regarding this. Check out this question Load an SWF into a WebView
The author their says that you must enable plugins for thewebview
webview.getSettings().setPluginsEnabled(true);
I want to display pdf contents on webview.
Here is my code:
WebView webview = new WebView(this);
setContentView(webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("URL/Demo_PDF.pdf");
Problem:
When i am trying to run the application, at that time I am getting blank screen.
And also, if there is any PDF viewer then also suggest me !!
FYI, I have already set internet permission.
Finally, i got a solution, actually i made a trick to load a pdf file using Google Docs inside a webview:
webview.loadUrl("http://docs.google.com/gview?embedded=true&url=http://myurl.com/demo.pdf");
I'm sorry but WebView does not display PDF content.
What you might want is a PDF viewer that responds to the PDF MIME type.
Here are a couple of free open-source libraries you might want to check:
droidreader
apv pdf reader
You can try using mupdf (www.mupdf.com)
You can build a native code library (libmupdf.so) to be loaded onto your android project using the ndk.
This would ensure a lot faster rendering of pdf files...
check out the project at : http://mupdf.com/repos/mupdf/android/
WebView does not have a PDF plugin. You should store the PDF locally and open an intent for viewing that kind of content.