I want to take the screen shot of current screen when,I click a button.Can anyone provide a android code.I need to save the image in the gallery also.this is what i tried
public class CaptureScreenShots extends Activity {
LinearLayout L1;
ImageView image;
 @Override
     protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.screen_shots);
    L1 = (LinearLayout) findViewById(R.id.LinearLayout01);
    Button but = (Button) findViewById(R.id.munchscreen);
    but.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            View v1 = L1.getRootView();
            v1.setDrawingCacheEnabled(true);
            Bitmap bm = v1.getDrawingCache();
            BitmapDrawable bitmapDrawable = new BitmapDrawable(bm);
            image = (ImageView) findViewById(R.id.screenshots);
            image.setBackgroundDrawable(bitmapDrawable);
        }
    });
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.screen_shots, menu);
    return true;
}
}
 
     
     
     
    