捕获WebView中的所有重定向URL

时间:2014-05-13 05:27:11

标签: android url webview

我将网址加载到WebView。它加载登录页面。登录后,用户将被重定向到不同的URL。当他到达最后一个网址时,他会通过身份验证。当最后一个url与我正在形成的String匹配时,我想加载另一个活动。

有关如何实现这一目标的任何帮助?

2 个答案:

答案 0 :(得分:0)

你似乎已经问过这个问题2-3次,现在我的朋友。

我不确定我是否对你的问题有正确答案。

如果我在你的位置,我会尝试使用一些工具来获取由于重定向而发生的所有网址。 尝试使用

等工具
  

http://redirectdetective.com/

     

http://www.internetofficer.com/seo-tool/redirect-check/

并在你的onPageFinished中 使用

获取webview的当前网址
String webUrl = webView.getUrl();

并将其与重定向后的最终URL进行比较 然后启动你的意图

答案 1 :(得分:0)

如果您想查看网址,请尝试以下代码:

webView.setWebViewClient(new WebViewClient(){
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if(url.contains("yourURL.com")){
            //Intent intent = new Intent(this, Test.class);
           //startActivity(intent);
                  webView.stopLoading(); //this line is to stop loading the webview
        }
        return true;
    }
});
相关问题