WebView showing blank white page when trying Facebook login
<p>I'm loading a webpage in a WebView. On clicking login through Facebook, I'm getting blank white screen. URL which is getting called is something like this: <code>https://m.facebook.com/dialog/oauth?access_token=...</code></p>

<p>Here's my piece of code:</p>

<p><strong>onCreate():</strong></p>

<pre><code>CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
WebSettings webSettings = wvMain.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setAppCacheEnabled(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
//webSettings.setSupportMultipleWindows(true);
wvMain.setWebChromeClient(new UriChromeClient());
wvMain.setWebViewClient(new UriWebViewClient());
wvMain.loadUrl(myUrl);
</code></pre>

<p><strong>UriWebViewClient</strong></p>

<pre><code>private class UriWebViewClient extends WebViewClient {

        @Override
        public void onReceivedError(WebView view, int errorCode,
                String description, String failingUrl) {
            super.onReceivedError(view, errorCode, description, failingUrl);
            wvMain.loadUrl(lastUrl);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            lastUrl = url;
        }

        @Override
        public void onReceivedSslError(WebView view, SslErrorHandler handler,
                SslError error) {
            super.onReceivedSslError(view, handler, error);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            try {
                if (url.startsWith("http:") || url.startsWith("https:")) {
                    return false;
                }

        else if (url.startsWith("tel:")) {
                    //do something
                    return true;
                } else if (url.startsWith("mailto:")) {
                    //do something
                    return true;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            return true;
        }

    }
</code></pre>

<p><strong>UriChromeClient</strong></p>

<pre><code>class UriChromeClient extends WebChromeClient {

    @Override
    public boolean onCreateWindow(WebView view, boolean isDialog,
            boolean isUserGesture, Message resultMsg) {
        WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
        transport.setWebView(wvMain);
        resultMsg.sendToTarget();

        return true;
    }

    @Override
    public void onCloseWindow(WebView window) {
    }
}
</code></pre>

<p>Is I set <code>webSettings.setSupportMultipleWindows(true);</code> in onCreate(), app crashes with following exception: <em>IllegalArgumentException: Parent WebView cannot host it's own popup window. Please use WebSettings.setSupportMultipleWindows(false)</em></p>

<p>Any help appreciated. I'm stuck on this from many days.</p>

<p><strong><em>EDIT:</em></strong>
Based on linked question in comment, I changed my <code>onCreateWindow</code> as follows:</p>

<pre><code>class UriChromeClient extends WebChromeClient {

    @Override
    public boolean onCreateWindow(WebView view, boolean isDialog,
            boolean isUserGesture, Message resultMsg) {
        WebView wvMain = new WebView(mContext);
        wvMain.setVerticalScrollBarEnabled(false);
        wvMain.setHorizontalScrollBarEnabled(false);
        wvMain.setWebViewClient(new UriWebViewClient());
        WebSettings webSettings = wvMain.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setAppCacheEnabled(true);
        webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
        webSettings.setSupportMultipleWindows(true);
        wvMain.setLayoutParams(new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        mContainer.addView(wvMain);
        WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
        transport.setWebView(wvMain);
        resultMsg.sendToTarget();

        return true;
    }
}
</code></pre>

<p>Now app doesn't crash, but same white/blank screen issue is there.</p>