Here is the full solution for WebView.
private void loadWebView(String myUrl) {
WebView webView = findViewById(R.id.webView);
ProgressDialog progressdialog = new ProgressDialog(StartModelTest.this);
progressdialog.setMessage("Please wait...");
progressdialog.setCanceledOnTouchOutside(false);
/* JS start*/
WebSettings settings = webView.getSettings();
settings.setDomStorageEnabled(true);
settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
/* JS start*/
Log.d("TAG", "loadWebView: "+myUrl);
webView.loadUrl(myUrl);
webView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
if (!progressdialog.isShowing()) {
Log.d("TAG", "Started: ");
progressdialog.show();
}
}
public void onPageFinished(WebView view, String url) {
if (progressdialog.isShowing()) {
progressdialog.dismiss();
Log.d("TAG", "Finished: ");
}
//Log.d("TAG", "onPageFinished Bool: " + url.contains("home"));
if (url.contains(Util.CLOSING_TAG)) {
finish();
}
}
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
if (progressdialog.isShowing()) {
progressdialog.dismiss();
Log.d("TAG", "Err: ");
}
}
});
}