When I call WebView#loadUrl I expect that I should only get a single WebViewClient#onPageFinished call and no WebViewClient#shouldOverrideUrlLoading call. However, I get a WebViewClient#shouldOverrideUrlLoading (which I implement by always calling WebView#loadUrl and returning true) and then two WebViewClient#onPageFinished calls with the same URL.
The page I'm loading uses a lot of ajax requests. Do ajax requests invoke the WebViewClient? My page does not have any meta-refreshes in it.
This is quite frustrating. Am I doing something wrong?
This is a cross-post from a google groups discussion I started on the topic.
I've done more research, and I think I understand everything that's going on.
Here is my
WebViewClient:I have the following URL redirects from my server:
These URLs are part of a server that I don't control, so I just have to deal with the behavior.
Here is the output from loading
http://example.com/resourceat this point, my
WebViewhas blank content. I must wait until after the secondonPageFinishedto grab my content.Here is the output from loading
http://example.com/logout.jspagain, at this point, my
WebViewhas a blank page. I have to wait until the 3rdonPageFinishedto get my content from theWebView.Based on the documentation, I don't expect this behavior. Notice that there is an unbalanced number of
onPageStarteds andonPageFinisheds. I especially dislike howonPageFinishedgets called with my redirected URL, yet theWebViewdoesn't contain my content. I understand that this behavior is probably unchangeable, but this unexpected behavior should at least be documented.