Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a callback when WebView has rendered data (is ready to be displayed)

Tags:

android

I use WebView in a dialog and at the first launch it takes up to 1 second to render very simple content. The content is set from code as a String (no loading from network). At the beginning for a while I see empty dialog and then the content appears. How to set a callback for the moment when WebView is ready to be displayed and then call show on an AlertDialogBuilder? I have tried WebViewClient.onPageFinished, WebViewClient.PictureListener.onNewPicture, WebChromeClient.onProgressChanged (==100) with no effect.

like image 654
Urboss Avatar asked Nov 14 '22 00:11

Urboss


1 Answers

webViewInstance.setPictureListener(new PictureListener() {      
   @Override
   public void onNewPicture(WebView view, Picture picture) {
      // the code goes here
   }
});
like image 182
Dmitry S. Avatar answered Dec 23 '22 04:12

Dmitry S.