I want to take screenshot of an activity and show it in next activity on button click.
I'm using following code but its not working.
Please let me know if anyone knows the answer:
choose.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mainlayout.setDrawingCacheEnabled(true);
mainlayout.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
mainlayout.layout(0, 0, mainlayout.getMeasuredWidth(), mainlayout.getMeasuredHeight());
mainlayout.buildDrawingCache(true);
Bitmap b = Bitmap.createBitmap(mainlayout.getDrawingCache());
mainlayout.setDrawingCacheEnabled(false); // clear drawing cache
Intent i4=new Intent(Screen3.this,Screen4.class);
i4.putExtra("BitmapImage", b);
startActivity(i4);
}//onclick
});