I want to know how to determine when a WebView is completely done loading.
Let me define completely.
- All redirects have happened
- The page is visibly displayed, nothing has yet to load
Bad answers to this question:
WebViewClient.onPageFinished()
- this fires multiple times if there are redirects loading a page. It also fires before the page is displayed.
PictureListener.onNewPicture()
- this fires every time the screen changes and AFAICT each redirect. How would I know which firing is the final one?
WebChromeClient.onProgressChanged()
- same problem as onPageFinished. (Added after David suggested this solution below)
Thread.sleep(5000)
- should be obvious, why this isn't acceptable.
Of course, a clever combination of the above that works would be perfect.
Why do I want to know this you ask? Because I want to inject some javascript one time once the webview is completely done loading.