I need to know when a page really finishes loading
I am quite new to Android yet, and I have an application that has a webview on it.
I need to know when the webview finishes loading a page that has a ran开发者_StackOverflow社区dom number of redirects (sometimes to the same page, and the order of the redirects also change), so I can remove the Splash Screen only when there is a fully loaded page.
On the webviewclient the onPageStarted and onPageFinished functions are called once per each redirect, as is the onNewPicture (even though the screen is always blank during the redirects). So I can't be sure when it's called the last time (page actually loaded).
I also tried using the onLoadResource to count the number of resources loaded (dangerous and unreliable approach, but I am getting desperate here), but this also failed, since after the page is cached, it is called only one or two times.
That is one big puzzle I am unable to solve using what I know so far, can anyone please help me?
Thanks a lot in advance.
Off the cuff, it sounds like you have a Web site that needs to be rewritten... :-)
Here are two possibilities I can think of:
- If you get an
onPageFinished()
and noonPageStarted()
after such-and-so period of time, assume the redirects are done. - If these redirects are all HTTP redirects (3xx response status codes), you could use HttpClient to navigate the redirects until you get the final URL, then give that URL to
WebView
to display.
精彩评论