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);
Related
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");
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);
I am trying to display a PDF to a web page using the html [object] tag. This works fine on all the web browsers on PC's as well as iPhone/iPad. But when I load the same page on an Android it asks me if I want to download the file which is the backup when the PDF isn't displayed. Does anyone know why this wouldn't work or another html control I could use rather than forcefully calling the local PDF program on the phone.
Below is how my html is rendered.
<object data="../myFile.pdf" type="application/pdf" width="100%" height="100%">
<p>Missing PDF plugin for this browser.Click here to download the PDF file.</p>
</object>
I have also seen examples on stackoverflow suggesting the below code but I am unsure of how to leverage it on my site and was hoping there was a possible html fix.
WebView webview = new WebView(this);
setContentView(webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("URL/Demo_PDF.pdf");
The phone I am using is a Thunderbolt. Thanks for the help.
Does anyone know why this wouldn't work
Because that is not supported on Android.
or another html control I could use rather than forcefully calling the local PDF program on the phone.
There may not even be a "local PDF program on the phone". Many phones ship with one, many users install one, but there is no guarantee.
But, beyond that, there is no way to display PDFs natively inline in the stock Android browser. A third party one might support it (e.g., Firefox). Converting the PDF to a Flash animation might work with the stock Android browser, though that will only work on Android 2.2 and higher.
but I am unsure of how to leverage it on my site
You wouldn't. That is Java code, for an Android application.
My application has one button. If you click that button then it will display the web pages based on the web service response using webview.
It works properly for general links. But for links that have .pdf, a white screen gets displayed.
Is it possible to display the .pdf file using web view?
Would appreciate any help.
i used the following code
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.loadUrl("http://docs.google.com/gview?embedded=true&url="
+"http://www.kim-lai.com/images/Menu_100309.pdf");
It sounds like it could be trying to but there is no direct pdf rendering support in webview. Please look at the following question
android webview pdf
You may find the following question useful also
how to open a pdf file inside a webview for android?
EDIT
Android - Load PDF / PDF Viewer
Please also make sure you ask appropriate questions, prefrerably with code so that others can reproduce your problem and offer a solution. Do your own research!!! Stack overflow is not a magic site that does your work for you!!!
ADENDUM
You require internet permissions. Add this to your manifest.xml
SUPPLEMENTAL
I tried typing in the url into the browser and it tells me "Sorry, we are unable to retrieve the document for viewing or you don't have permission to view the document. "
mWebView.loadUrl("http://www.kimlai.com/images/Menu_100309.pdf");
Try like this, what do you see?
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.