I have a scenario where on a page I can have multiple WebViews that can dynamically load, all at the same time. For example the user may have defined a Google and Yahoo link on the same page. All fine and dandy. What I need though is a way to show that a web view is being loaded without the standard Loading progress dialog since that will freeze the screen. Rather I would like to either show an image in the web view itself saying the web view is loading or have an indicator INSIDE the webview that does not affect the users ability to add data in case the loading of the multiple web views takes a while.
I attempted to load an image in the web view(s) just before loading the real urls, but it seems to either be ignored or immediately overwritten.
thanks!
I am working on an android app that displays Web Content that it obtains from a Web site. The app obtains this content from a Web page. The problem is I want to display a particular portion of the Web page, not the whole thing as the whole thing contains excess unwanted content. How can I display the data I need?
you need to download HTML code without WebView first. Then process it removing unwanted data, and then load resulting HTML into WebView
I need to create an android browser in Yoruba language. I have already used webviews to create one in English language. What i wnt to do is to get the content of each page as it loads.
If i can get the whole content of a page into an array, i will be happy so i can now send the content to google translate api to translate to Yoruba and the some how i will replace the engliah in the html with the Yoruba strings.
I want to be able to do this on the fly before the page finish loading.
I have already developed an engliah browser and i know how to work with api. I just need to get the content of a webview page into an array and be able to replace after translation
I'm trying to load a url in webview in android. The url loads fine in the web view. But the problem is the loading time of the webpage in the webview. Sometimes the webpages loads instantly within 1-2 seconds. But sometimes, the web page takes more than 40 seconds to load the webpage in the web view. When I checked the url on the browser, it loads within or less than 2 seconds. The problem is that when the web page takes more than 2 seconds, the white color of the webview is only showing and the users are thinking that the app is stuck or not responding. So they are complaining about the loading time. Is there any way to rectify this problem.
The best way to load content coming from internet is to use separate processes than the main one.
An example is:
you click to open the webview;
the app doesn't launch the webview activity but a splash screen with the "Loading..." information (plus a logo or an icon);
this splashscreen activity verifies if the internet connection is
available; if so, the splash activity launch an AsyncTask which, in a
separate backgorund thread, download the necessary HTML page (or XML file, etc);
when the content is correctly downloaded, the splash activity calls
the Webview activity, giving the necessary data trough an Intent.
This way is commonly used to load internet content on apps; it allows the operator to don't see a freezed activity but a window which suggest that a process is on-going.
Please find here the official information regarding AsyncTask.
A classic example which uses the SplashScreen/AsyncTask/BackgroundProcess is a RSS Reader; please find here a source code which can help you to understand (check out the SplashScreenActivity).
This is one way to do it, but it's not the only one.
I had similar problem on Android 4.4 version. This worked for me
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
It is due to some bug in webview for Kitkat version.
This might seem to you guys as a stupid question, but it comes into my mind so many times:
Why is there an ImageView in Android? We have a WebView, which is capable of displaying images, and so much more stuff. So why would you provide an ImageView as well? Maybe there is some fundamental reason for this, but I just don't see it. Whenever I want to use some media, I try to use a WebView, because this allows me to change the type of media if I wish to do so, and I do not need another Type of View.
So to not make this question to broad, let's bring it down to this:
In which scenario does an ImageView have big advantages over a WebView?
EDIT
And a second question:
If I have some audio, some html-text and some pictures, which are stored locally on my device, would I use one WebView to display them, or would I use one Type of View for each Type of media?
WebView is a much more expensive widget to use, in terms of memory consumption, than is ImageView.
The reason for the memory cost of WebView is the fact that WebView is powered by a fairly complete copy of WebKit. WebKit is an open source Web rendering engine that forms the heart of major Web browsers, such as Chrome and Safari. While the version of WebKit that lives in Android is one optimized for mobile use, it still represents a fairly substantial code base, and rendering complex Web pages takes up a fair amount of RAM (as anyone with lots of browser tabs on their desktop knows all too well).
FACT: The WebView implementation is such that it will consume more memory if used to download & display images. Always. Also, ImageView has special methods / XML tags for cropping, resizing, scaling & manipulating images (which WebView doesn`t).
A person has a image in the gallery. The persom wants to show it inside the app. What will it do?
Go and host it on an online image hosting website and then pass the url to the WebView?
That ain't a cool Idea.. and people and Google understand that.
Basically image view using for showing image from gallery , drawable or url.Webview for handling or showing web content or html kind of thing.
Well ImageView consumes less memory. ImageView can change the image display options.
ImageView can display images from different sources like "Resources, drawables".
WebView mainly for displaying html pages.