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.
try the following : webView.loadData("");
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With