Created
November 26, 2014 05:24
-
-
Save januprasad/61e3e26cc22cc55f0f9b to your computer and use it in GitHub Desktop.
takeScreenshot take screenshot of android device
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment