我需要知道页面何时真正完成加载
我对 Android 还很陌生,我有一个带有 webview 的应用程序。
我需要知道 webview 何时完成加载具有随机数量的重定向的页面(有时到同一页面,并且重定向的顺序也会改变),所以仅当页面已完全加载时,我才能删除启动屏幕。
在 webviewclient 上,每个重定向都会调用 onPageStarted 和 onPageFinished 函数一次,就像 onNewPicture 一样(即使在重定向期间屏幕始终为空白)。所以我无法确定最后一次调用它是什么时候(页面实际加载)。
我还尝试使用 onLoadResource 来计算加载的资源数量(危险且不可靠的方法,但我在这里感到绝望),但这也失败了,因为页面被缓存后,它只被调用一两次。
这是我迄今为止所知道的一个大难题,无法解决,有人可以帮助我吗?
预先非常感谢。
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 random 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
即兴地说,听起来您有一个需要重写的网站...:-)
我能想到的有两种可能性:
onPageFinished()
并且没有onPageStarted()
经过一段时间后,假设重定向已完成。WebView
进行显示。Off the cuff, it sounds like you have a Web site that needs to be rewritten... :-)
Here are two possibilities I can think of:
onPageFinished()
and noonPageStarted()
after such-and-so period of time, assume the redirects are done.WebView
to display.