Example usage for android.webkit WebView setDrawingCacheEnabled

List of usage examples for android.webkit WebView setDrawingCacheEnabled

Introduction

In this page you can find the example usage for android.webkit WebView setDrawingCacheEnabled.

Prototype

@Deprecated
public void setDrawingCacheEnabled(boolean enabled) 

Source Link

Document

Enables or disables the drawing cache.

Usage

From source file:Main.java

public static Bitmap getWebViewShopshat(WebView webView) {
    webView.setDrawingCacheEnabled(true);
    webView.buildDrawingCache();/*from  ww  w  .  j  a  v a 2  s  .  c om*/
    Picture snapShot = webView.capturePicture();
    Bitmap bitmap = Bitmap.createBitmap(snapShot.getWidth(), snapShot.getHeight(), Bitmap.Config.ARGB_8888);
    //bitmap.eraseColor(Color.WHITE);

    Canvas c = new Canvas(bitmap);
    int state = c.save();
    webView.draw(c);
    //c.restoreToCount(state);
    c.restore();
    webView.destroyDrawingCache();

    return bitmap;
}

From source file:Main.java

public static Bitmap getBitmapForVisibleRegion(WebView webview) {
    Bitmap returnedBitmap = null;//from w  w w . jav a2s. c  o  m
    webview.setDrawingCacheEnabled(true);
    returnedBitmap = Bitmap.createBitmap(webview.getDrawingCache());
    webview.setDrawingCacheEnabled(false);
    return returnedBitmap;
}