Android WebView - 将 url 重定向到,而不在 webview 中加载页面

Android WebView - get url redirected to, without loading the page in the webview

我正在尝试访问 a.com,这又将我重定向到 b.com 并将其加载到网络视图中。

如何只获取 a.com 重定向到的地址而不在 webview 中加载任何内容?

String postData = "session=" + session;
    webView.postUrl(urlPassedFromArguments,
            EncodingUtils.getBytes(postData, "base64"));

    webView.setWebViewClient(new WebViewClient() {

        @Override
        public void onReceivedError(WebView view, int errorCode,
                String description, String failingUrl) {

            if (isAdded() && getActivity() != null)
                Toast.makeText(getActivity(), description,
                        Toast.LENGTH_SHORT).show();

        }

        @Override
        public void onPageFinished(WebView view, String url) {
            try {
                dialog.dismiss();
            } catch (Exception e) {
            }
            super.onPageFinished(view, url);
            Logger.e("onPageFinished url", url);

            if (!resolvedUrlLoaded) {
                String postData = "token=" + token;
                webView.postUrl(url,
                        EncodingUtils.getBytes(postData, "base64"));
                resolvedUrlLoaded = true;
            }
        }

    });

使用shouldOverrideUrlLoading:

@Override
public boolean shouldOverrideUrlLoading (WebView view, String url) {
    // url to be loaded
    return true|false;
}

Returns True if the host application wants to leave the current WebView and handle the url itself, otherwise return false.