After some research I conclude that despite what most of the tutorials out there say, shouldOverrideUrlLoading()
does not get called when:
-
You load a URL like
loadUrl("http://www.google.com");
-
The browser redirects the user automatically via an HTTP Redirect. (See the comment from @hmac below regarding redirects)
It does however, get called when you you click on a link inside a webpage inside the webview. IIRC the twitter authorization uses an HTTP Redirect.. Bummer, this would be helpful if it worked how all the tutorials say it does. I think this is from a very old version the Android API…
You might want to consider overriding the onProgressChanged
method of a WebChromeClient
like here: How to listen for a WebView finishing loading a URL? or the onPageFinished()
method of the WebViewClient
.