I have an activity with some views, after doing some stuff I want to convert the look of this activity into an image and email it. I can mail an image, but how can i make that activity into an image? Is it possible?
Asked
Active
Viewed 1,241 times
3
-
1Try SO - [http://stackoverflow.com/questions/3067586/how-to-capture-the-android-device-screen-content][1] [1]: http://stackoverflow.com/questions/3067586/how-to-capture-the-android-device-screen-content – karakuricoder Mar 26 '12 at 20:13
2 Answers
0
You can render different views of your app to Bitmap
Objects, by capturing the drawing cache
.
just refer to http://blog.neurolive.net/2010/11/385/ for more details. (thx, for the great tutorial)
especially
private Bitmap getScreenViewBitmap(View v) {
v.setDrawingCacheEnabled(true);
// this is the important code :)
// Without it the view will have a dimension of 0,0 and the bitmap will be null
v.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight());
v.buildDrawingCache(true);
Bitmap b = Bitmap.createBitmap(v.getDrawingCache());
v.setDrawingCacheEnabled(false); // clear drawing cache
}
seems what you would be interested in. (Just find your top-level View and use this method to capture the Bitmap)

saberrider
- 585
- 3
- 16