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/resource
at this point, my
WebView
has blank content. I must wait until after the secondonPageFinished
to grab my content.Here is the output from loading
http://example.com/logout.jsp
again, at this point, my
WebView
has a blank page. I have to wait until the 3rdonPageFinished
to get my content from theWebView
.Based on the documentation, I don't expect this behavior. Notice that there is an unbalanced number of
onPageStarted
s andonPageFinished
s. I especially dislike howonPageFinished
gets called with my redirected URL, yet theWebView
doesn't contain my content. I understand that this behavior is probably unchangeable, but this unexpected behavior should at least be documented.