androidandroid-webviewandroid-websettings

Android webview : Url not completely loaded in webview whereas in chrome it's OK


I tried to load an url in a webview but this url is not completely loaded :

enter image description here

Whereas, in Chrome app, the url is successfully loaded :

enter image description here

Here is the code that i used :

mWebView.setWebViewClient(new myWebClient());

        mWebView.getSettings().setUseWideViewPort(true);
        mWebView.getSettings().setSupportZoom(true);
        mWebView.getSettings().setBuiltInZoomControls(true);
        mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
        mWebView.getSettings().setSupportMultipleWindows(true);
        mWebView.getSettings().setAllowFileAccess(true);
        mWebView.getSettings().setDomStorageEnabled(true);
        mWebView.getSettings().setSavePassword(true);

        mWebView.loadUrl(mUrl);  

And my myWebClient class:

public class myWebClient extends WebViewClient {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
    // TODO Auto-generated method stub
    super.onPageStarted(view, url, favicon);
    progressB.setVisibility(View.VISIBLE);
}

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    view.loadUrl(url);
    progressB.setVisibility(View.VISIBLE);
    return true;
}

public void onProgressChanged(WebView view, int progress) {
    progressB.setProgress(progress);
}

@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    progressB.setVisibility(View.GONE);
}
}

Solution

  • seems like you are missing the setting:

    mWebView.getSettings().setJavaScriptEnabled(true);
    

    without this call javascript won't work