Screenshot of a web page with Flash elements

I would like to take a screenshot of the page displayed in the WebView. The page contains flash elements - and this is the problem. When I take a screenshot, all the flash parts of the page are empty.

I use this code snippet to take a screenshot:

WebView webView = (WebView) findViewById(R.id.webview);
Picture picture = webView.capturePicture();
Bitmap screenshot = Bitmap.createBitmap(picture.getWidth(),
        picture.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(screenshot);
picture.draw(c);

File file = new File("/sdcard/screenshot.jpg");
FileOutputStream ostream = null;
try {
    file.createNewFile();
    ostream = new FileOutputStream(file);
    screenshot.compress(CompressFormat.JPEG, 90, ostream);
    Log.d("Test", "Screenshot taken");
} catch (Exception e) {
    Log.e("Test", "Error", e);
} finally {
    try {
        ostream.close();
    } catch (IOException ignore) {
    }
}

I also tried to get the Bitmapcontents of the screen using the solution mentioned in this SO question :

View webView = findViewById(R.id.webview);
Bitmap bitmap = webView.getDrawingCache();

This also does not work - the result is the same (i.e. empty flash elements).

So the question is: How do I take a screenshot of WebView content also with flashes?

+3
source share

All Articles