Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webview.loadUrl("about:blank") issue

In my application I have a webview in which initially I load any website, say www.google.com.
Later on a button click I want to clear this webview, for which I do

webview.loadUrl("about:blank");  

But doing this does not clear my webview, it continues to display google.com

I tried to re initialize the webview as

webview = new WebView(this);
webview.loadUrl("about:blank");

I also tried

webview.clearHistory();
webview.loadUrl("about:blank");  

But I got the same results, the webview displays google.com
How can I clear the webview?
Please suggest.
Thank You.

Edit:
On the other hand, before loading google.com if I do

webview.loadUrl("about:blank");  

it loads a blank webpage.

like image 487
Zeba Avatar asked Oct 17 '12 09:10

Zeba


2 Answers

try the following : webView.loadData("");

like image 158
Sameer Avatar answered Sep 22 '22 06:09

Sameer


just to update, method clearView() was deprecated in API level 18.

Use WebView.loadUrl("about:blank") to reliably reset the view state and release page resources (including any running JavaScript).

like image 26
MartinC Avatar answered Sep 21 '22 06:09

MartinC