Is there a better way to refresh WebView?
You could call an mWebView.reload();
That's what it does
1) In case you want to reload the same URL:
mWebView.loadUrl("http://www.websitehere.php");
so the full code would be
newButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
dgeActivity.this.mWebView.loadUrl("http://www.websitehere.php");
}});
2) You can also call mWebView.reload()
but be aware this reposts a page if the request was POST, so only works correctly with GET.
The best solution is to just do webView.loadUrl( "javascript:window.location.reload( true )" );
. This should work on all versions and doesn't introduce new history entries.
This worked for me.
just put under onCreate metode
Button button = (Button) findViewById(R.id.reload_btn);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
web.loadUrl( "javascript:window.location.reload( true )" );
}
});
This is the code that can reload a website in a webView
web.loadUrl( "javascript:window.location.reload( true )" );