EDIT: I worked on this project years ago and unfortunately I cannot verify if any of the answers is working in the given scenario.
I am having hard time with one Web
@override
public void onFormResubmission(WebView view, Message dontResend, Message resend){
resend.sendToTarget();
}
I faced the same issue and none of the above solution worked for me. So I fixed it by reloading WebView using JavaScript as follows:
webView.loadUrl( "javascript:window.location.reload( true )" );
Also JavaScript needs to be enabled for the WebView:
webView.getSettings().setJavaScriptEnabled(true);
Use exact in below sequence.
wv.clearCache(true);
wv.clearView();
wv.reload();
wv.loadUrl("about:blank");
wv.loadData(Constants.BLOG_URL);
Call this method in onPause()
private void pauseWebView() {
try {
Class.forName("android.webkit.WebView")
.getMethod("onPause", (Class[]) null)
.invoke(webview, (Object[]) null);
} catch(ClassNotFoundException cnfe) {
} catch(NoSuchMethodException nsme) {
} catch(InvocationTargetException ite) {
} catch (IllegalAccessException iae) {
}
}
Just make a method in which you'll flush an reinitialize whole WebView and call it from reLoadUrl().
void loadWebView() {
wv = (WebView) findViewById(R.id.blog_webview);
wv.getSettings().setJavaScriptEnabled(true);
wv.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon {
MyLog.logDump("onPageStarted: " + url);
}
@Override
public void onPageFinished(WebView view, String url) {
MyLog.logDump("onPageFinished: " + url);
}
});
wv.loadUrl(Constants.BLOG_URL);
}
public void reLoadUrl() {
loadWebView();
}
I was facing the same problem and finally able to manage to solve this.I am new to android not sure this good or bad but it works for me.I simply clear catch from web view and destroy and re-create before reloading another url .
mWebView.clearCache(true);
// destroy before reload new url
parentView.removeView(mWebView);
mWebView.clearHistory();
mWebView.destroy();
Though mWebView.destroy(); generate an error "java.lang.Throwable: Error: WebView.destroy() called while still attached!" and i search it but does not get any solution and many say it does not affect application till now(I still does not know solve this N.B: I use WebChromeClient ) .