跟踪网址重定向android

时间:2014-03-10 04:34:38

标签: android url redirect webview

我正在将{0}加载到我的WebView。它是用于登录网站的网址的网址。我希望跟踪所有重定向的URL,尤其是在用户登录后加载页面时的最后一个URL。

知道如何做到这一点?

3 个答案:

答案 0 :(得分:0)

试试这个:

webView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    Intent intent = new Intent(this, YourActivity.class);
    intent.putExtra("url", url);
    startActivity(intent);
    return true;
  }
  }

另见here

答案 1 :(得分:0)

检查答案shouldOverrideUrlLoading is not detecting Hash url change for inside view in html5,其中shouldOverrideUrlLoading方法返回您可以存储的加载网址,并根据您的要求进行检查

答案 2 :(得分:0)

each and every url which is loading in webview can be tracked through 
public void onPageFinished(WebView view, String url) {
            //url parameter is the one which we needed
        }

this methods belongs to 
private WebViewClient webViewClient = new WebViewClient() {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
                    return true;
        }


        public void onPageFinished(WebView view, String url) {

        }

        public void onPageStarted(WebView view, String url, android.graphics.Bitmap favicon) {

        };

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

        }
    };