【问题标题】:Track url redirection android跟踪 url 重定向 android
【发布时间】:2014-04-13 01:58:52
【问题描述】:

我正在将一个 URL 加载到我的 WebView 中。它是网站登录页面的 URL。我想跟踪所有重定向的 url,尤其是在用户登录后页面加载时的最后一个。

知道如何做到这一点吗?

【问题讨论】:

  • webview中实现webviewclient
  • @SimplePlan 我已经完成了。但是我要覆盖哪些方法?

标签: android url redirect webview


【解决方案1】:

试试这个:

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

【讨论】:

    【解决方案2】:

    检查答案 shouldOverrideUrlLoading is not detecting Hash url change for inside view in html5 中的 shouldOverrideUrlLoading 方法返回加载 url,您可以根据自己的要求存储和检查

    【讨论】:

      【解决方案3】:
      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) {
      
              }
          };
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-06-09
        • 1970-01-01
        • 1970-01-01
        • 2012-06-13
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多