Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebView Display White or Blank page

does anyone know why webview displaying white page? Here is the code

webView = (WebView) this.findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(THE_URL);
webView.setWebViewClient(new WebViewClient());

and this functions is also called:

@Override
public void onPageFinished(WebView view, String url) {
}

am I missing something there? Of course, the error is not from the XML, because the webview only does not display some URL.

Thanks

like image 239
Rendy Avatar asked Apr 30 '12 08:04

Rendy


People also ask

How do I display HTML content in WebView?

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. In the above code, we have taken web view to show html content.

What can I use instead of WebView?

Alternatives to WebView If you want to send users to a mobile site, build a progressive web app (PWA). If you want to display third-party web content, send an intent to installed web browsers. If you want to avoid leaving your app to open the browser, or if you want to customize the browser's UI, use Custom Tabs.

How can I improve my WebView performance?

Enhance webView performance - disable the WebView cache to make WebView much faster. Supercharging the Android WebView - cache critical assets that drastically reduce the load time.

What is a WebView page?

If you want to deliver a web application (or just a web page) as a part of a client application, you can do it using WebView . The WebView class is an extension of Android's View class that allows you to display web pages as a part of your activity layout.


2 Answers

For anyone still having this issue, it seems that the WebViewClient does not warn you if a secure connection via https has failed. This is likely due to an SSL error on the server you are connecting to.

You can try using http instead if the server allows it.

like image 165
Dom Avatar answered Sep 17 '22 16:09

Dom


Refer this link. In your code you are creating two webview clients simultaneously.

mwebview=(WebView)findViewById(R.id.webview);
mwebview.getSettings().setJavaScriptEnabled(true);
mwebview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
mwebview.loadUrl(webUrl);
mwebview.setWebChromeClient(new WebChromeClient() );
like image 24
Shankar Agarwal Avatar answered Sep 17 '22 16:09

Shankar Agarwal