How to convert an activity to an image

I have an activity with some views, after doing some actions, I want to convert the appearance of this activity to an image and send it via email. I can send an image by email, but how can I make this activity into an image? Is it possible?

+3


source to share


2 answers


You can programmatically take a screenshot of your device, which should do the trick. Take a look at this SO answer> it should get you started.



+2


source


You can map different views of your application to Bitmap

Objects by capturing drawing cache

.

just refer to http://blog.neurolive.net/2010/11/385/ for more details. (thanks, for a great tutorial)

special



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
}

      

it seems that you are interested. (Just find your top level view and use this method to capture Bitmap)

0


source







All Articles