List of usage examples for android.view ViewGroup buildDrawingCache
@Deprecated public void buildDrawingCache()
Calling this method is equivalent to calling buildDrawingCache(false)
.
From source file:Main.java
/** * Take screenshot of the activity including the action bar * //www.j a va 2 s.c o m * @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; }