开发者

Screenshot of a webpage with Flash elements

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

I am using this piece of code 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 was also trying to acquire Bitmap of the screen contents u开发者_如何学编程sing the solution given in this SO question:

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

This also doesn't work - the result is the same (i.e. blank flash elements).

So the question is: How to take a screenshot of WebView contents also with flash elements?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜