Search code examples
androidandroid-webviewinterception

Notify on webView.loadDataWithBaseURL()


I am trying to inject some Javascript into my web view immediately after loading data into my web view via webView.loadDataWithBaseURL() but I have no way of knowing when the data is actually finished loading. Is this method synchronous? Can I just rely on the data being immediately loaded since it comes from memory? I'm asking because it seems as if my injected Javascript is not seeing elements on the page. I'm assuming it's because the view has not loaded before injecting the JS. (I have yet to prove this.)


Solution

  • You can register a WebViewClient with your WebView using setWebViewClient() and implement its onPageFinished() to know when the page is done loading.