2

I have a GridView to show images. Every image click show the list activity as dialog based on same position. When I click the back button, I need to capture a screen shot of the list activity. How can I do this?

Here is an example to work, but it doesn't capture the list activity as dialog activity.

View v1 = getWindow().getDecorView().getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bm = v1.getDrawingCache();
BitmapDrawable bitmapDrawable = new BitmapDrawable(bm);             
holder.cardBack.setBackgroundDrawable(bitmapDrawable);
// holder.cardBack.setBackgroundResource(R.drawable.a);
holder.rootLayout.startAnimation(flipAnimation);
Rafael Tavares
  • 5,678
  • 4
  • 32
  • 48
  • check this link ,Hope it helps you http://stackoverflow.com/questions/2661536/how-to-programatically-take-a-screenshot-on-android – Rajesh Mikkilineni Jul 31 '14 at 12:17
  • @RajeshM Ok thanks. this code has work. i have created activity as dialog. how can i capture front of screen. how can apply imageview on gridview – user3825313 Jul 31 '14 at 12:21

1 Answers1

0

try this, Call this method, passing in the outer most ViewGroup that you want a screen shot of:

public Bitmap screenShot(View view) {
    Bitmap bitmap = Bitmap.createBitmap(view.getWidth(),
            view.getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    view.draw(canvas);
    return bitmap;
} 

Ref : How to programmatically take a screenshot in Android?

Community
  • 1
  • 1
Rajesh Mikkilineni
  • 854
  • 10
  • 22