I'm trying to load a web in a webview, but when the page is loaded, the webview carry on refreshing the view in a loop. How I can avoid this?
My code to load the page is the next:
In the onCreateView:
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(pathto.get_register_service());
webView.setWebViewClient(new RegisterWebViewClient());
webView.invalidate();
The custom class of the WebViewClient:
private class RegisterWebViewClient extends WebViewClient {
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
view.loadUrl(url);
progressWheel.setVisibility(View.GONE);
ll_error_message.setVisibility(View.GONE);
webView.setVisibility(View.VISIBLE);
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
super.onReceivedError(view, errorCode, description, failingUrl);
progressWheel.setVisibility(View.GONE);
ll_error_message.setVisibility(View.VISIBLE);
webView.setVisibility(View.GONE);
}
}
You are reloading page in onPageFinished
event with view.loadUrl(url);
onPageFinished
is triggered when page has finished loading and you should not reload the page inside that event or you will end up in endless loop.