I need to create a WebView (never shown on screen, only for internal purposes), use it to load a page, and then draw that page to an offscreen bitmap for later use.
I've tried all sorts of things, but having no luck.
I'm creating the WebView with:
I'm then using [font=Courier New]webView.loadUrl(url)[/font] to load the web page I need to draw.
I then attempt to call the method to draw the page to a Bitmap from an attached WebViewClient's [font=Courier New]onPageFinished[/font] method.
The first thing I tried for this was this:
No luck. All that is drawn is whatever is the WebView's BackgroundDrawable/BackgroundColor.
I figured maybe the correct size of the WebView might not be set, but not really sure what the right way to go about this I tried adding all sorts of variations on the following before the draw call:
I also tried [font=Courier New]webView.invalidate()[/font] and [font=Courier New]webView.postInvalidate()[/font] both before and after the draw call. Same result.
I also tried [font=Courier New]webView.capturePicture()[/font], but noticed that the resulting picture would always have a size of 0x0 (checked using [font=Courier New]picture.getWidth()[/font] and [font=Courier New]picture.getHeight();[/font].
I tried calling [font=Courier New]capturePicture()[/font] both in the method I call from onPageFinished as well as indirectly in an overloaded [font=Courier New]onDraw(...)[/font] method for the WebView. In both cases the resulting Picture had a size of 0.
Any help? What am I doing wrong?