List of usage examples for android.view ViewGroup getDrawingCache
@Deprecated public Bitmap getDrawingCache(boolean autoScale)
Returns the bitmap in which this view drawing is cached.
From source file:Main.java
/** * Take screenshot of the activity including the action bar * /*w ww . j a va 2s .com*/ * @param activity * @return The screenshot of the activity including the action bar */ public static Bitmap takeScreenshot(Activity activity) { ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView(); ViewGroup decorChild = (ViewGroup) decor.getChildAt(0); decorChild.setDrawingCacheEnabled(true); decorChild.buildDrawingCache(); Bitmap drawingCache = decorChild.getDrawingCache(true); Bitmap bitmap = Bitmap.createBitmap(drawingCache); decorChild.setDrawingCacheEnabled(false); return bitmap; }