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");
Related
I am creating an application and I am trying to load a HTML page in a web view.
I am using the code
WebView webView = (WebView)findViewById(R.id.webview);
webView.loadUrl("file:///android_asset/index.html");
but continue to receive an error that the web page at file:///android_asset/index.html might be temporarily down or it may have moved permanently to a new web address.
Any help would be great
from assets folder
webview.loadUrl("file:///android_asset/file.html");
from specific folder
webview.loadUrl("file:///data/data/com.example.example/files/file.html");
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 developing an android app. In that I have used webview to open the html page.
But some of the features on my HTML page would work only if I access the page through server.
How can I host the HTML page locally on my Android device?
For better Idea:
Example: On PC, I have hosted the html page locally using Apache Tomcat Server.
So to load this HTML page, I have two options
1. Directly double clicking the HTML and opening in browser.
2. Using URL: http://localhost:8080/MyWebApp
The first option is basic and some of features are not supported.
In second approach, all the features work as expected.
Is there any app/sdk/ open source which I can use to locally host the HTML page?``
try this code
webView = (WebView) findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
//webView.loadUrl("file:///android_asset/folderName/index.html");
webView.loadUrl("http://10.0.2.2:8080/MyWebApp");
Put your file to assets folder and write this
webView.loadUrl("file:///android_asset/help.html");
I am using a WebView to display this feedburner. When I view this link in Google Chrome and in the device's browser it shows the title, snippet, links, and most importantly a podcast file and other hyperlinks. However, when I view this link in my WebView it only shows it in Plain Text HTML with no hyperlinks. All i see is a title and the story snippet, followed by HTML source code. Is there a particular that must be enabled to resolve this?
These are my WebView settings:
newsfeed = (WebView) findViewById(R.id.webViewnews);
newsfeed.getSettings().setJavaScriptEnabled(true);
newsfeed.setVerticalScrollBarEnabled(false);
newsfeed.getSettings().setPluginsEnabled(true);
How I load the URL:
try {
newsfeed.loadUrl("http://feeds.feedburner.com/fsn");
} catch (Exception e) {
e.printStackTrace();
}
I'm seeing what you are seeing, list of entries with Title followed by html of article content on the Stock Browser - Motorola Droid running 2.2.3. My guess is that this is the format that the site provided for the stock Android WebView User Agent. Google Chrome is NOT the stock browser that comes with Android Open Source Project and does more under the hood to render content.
I would try a different user agent first to see if the webview will render the content. Note that they may be using various Javascript libraries which don't work well with Android which is why you are seeing the 'simplified' content.
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);