I am seeking to understand how to accurately determine when a WebView has finished loading in its entirety.
To clarify what is meant by "completely":
- All redirects have been processed
- The entire page is visibly displayed, with no additional elements left to load
Inappropriate solutions to this issue include:
WebViewClient.onPageFinished()
- triggers multiple times during redirect processes and before the full display of the page.
PictureListener.onNewPicture()
- fires whenever there are screen changes or redirects, making it difficult to pinpoint the final trigger.
WebChromeClient.onProgressChanged()
- faces the same challenges as onPageFinished. (Suggested by David)
Thread.sleep(5000)
- obviously not a suitable solution due to its interference with the loading process.
An optimal solution would involve cleverly combining the above methods in a way that effectively determines complete page loading.
Why do I aim to acquire this knowledge? Because I intend to inject specific javascript code once into the webview after it has fully loaded.