Screenshot of a webpage with Flash elements

可紊 提交于 2019-12-21 20:28:21

问题


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 using 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?

来源:https://stackoverflow.com/questions/6846796/screenshot-of-a-webpage-with-flash-elements

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!