1

When I'm loading a resource in a WebView, in Android, I simply call the typical mWebView.loadUrl(ht);.

The problem is that I would like to check the final url, and to perform some operation, when all the redirects are finished to be followed.

I mean: if I load example.com/page1, and this returns a 302 code that leads to another page (let's say, /page2), and this leads me again via a 302 redirection to another page (/page3), and this finally gives me a 200 and stops there, I would like to know when this happens.

It looks like I don't have the possibility to check the response code, nor the headers, and onPageFinished as well as shouldOverrideUrl are called for each redirect. It's kinda like "stateless"...

How can I distinguish between a typical 302 redirect, and the actual end of the loading process (200)?

Gian Segato
  • 2,359
  • 3
  • 29
  • 37
  • see this [Question](http://stackoverflow.com/questions/3149216/how-to-listen-for-a-webview-finishing-loading-a-url-in-android). – Harin Apr 03 '15 at 12:39

1 Answers1

-1

May be setting custom WebViewClient could help you:

 webView.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {
                super.onPageStarted(view, url, favicon);
            }

            @Override
            public void onPageFinished(WebView view, String url) {

            }
        });
Paul Freez
  • 1,059
  • 15
  • 27