I am try to load URL which internally redirect another URL in android WebView, but it is showing blank page. I have checked and found that I am trying to load http://erp1.stmarysschoolbxr.org/StudentReportCard.aspx?card=admitcard&AdmNo=22L001 which indirect to another URL http://erp1.stmarysschoolbxr.org/ReportPage.aspx but it is showing blank page. But when I try to load it in browser, it is loading fine.
Below is my webview code
binding.webView.getSettings().setJavaScriptEnabled(true);
binding.webView.getSettings().setLoadWithOverviewMode(true);
binding.webView.getSettings().setUseWideViewPort(true);
binding.webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, final String url) {
hideLoader();
}
@Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
super.onReceivedError(view, request, error);
hideLoader();
}
});
binding.webView.loadUrl(url);
}
According to WebView doc :
Note: Do not call WebView#loadUrl(String) with the request's URL and then return true.
This unnecessarily cancels the current load and starts a new load with the same URL.
The correct way to continue loading a given URL is to simply return false,
without calling WebView#loadUrl(String).
just return false in shouldOverrideUrlLoading without calling view.loadUrl(url);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.