I'm trying to load a URL in an android WebView, which is in a Activity. I was able to accomplish this, but the website was launching the default browser. I found the setWebViewClient method and it kept the website within the WebView inside of the app versus launching the default browser. However - this was showing a blank page. I tried other websites (http://www.google.com, http://www.amazon.com, etc) and these work...however the site that I am trying to get to load (https://mizaajindia.com/) does not.
I've set javascript enabled just in case - but cannot understand why some URLs would load and others wont from within the app's WebView. Would you have any ideas?
Thanks so much!
public class MainActivity1 extends AppCompatActivity {
private MainActivity1 activity;
private ProgressDialog progDailog;
private WebView webView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
activity = this;
progDailog = ProgressDialog.show(activity, "Loading", "Please wait...", true);
progDailog.setCancelable(false);
webView = (WebView) findViewById(R.id.wb_webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
progDailog.show();
view.loadUrl(url);
return false;
}
@Override
public void onPageFinished(WebView view, final String url) {
progDailog.dismiss();
}
});
webView.loadUrl("https://mizaajindia.com/");
}
}