I am trying to capture a image of a webview drawn off screen to the user in android and i always end up with a black image. It is the correct size and everything just not the
Here is the code I am using:
String theURL = "file:///android_asset/www/pages/page2.html";
WebView webview = new WebView(ctx);
webview.loadUrl(theURL);
Bitmap bm = Bitmap.createBitmap(1000, 1000, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bm);
webview.draw(c);
OutputStream stream = null;
try {
stream = new FileOutputStream(Environment.getExternalStorageDirectory() +"/page.jpg");
bm.compress(CompressFormat.JPEG, 80, stream);
if (stream != null) stream.close();
return new PluginResult(PluginResult.Status.OK);
} catch (IOException e) {
return new PluginResult(PluginResult.Status.ERROR, e.toString());
} finally {
bm.recycle();
}
Thanks if anyone can help.