I found some code that allows for screenshots of the activity. Although, I am running into a problem. It seems to "malfunction", for lack of a better term. Using some of the code from here, I set it up to where it will take the bitmap and put it into an image view using setimagebitmap. When I press the button to take the screenshot it works great the first time. The second time however, makes the image show an infinate amount of buttons, descending and getting smaller. I tried destroydrawingcache at the beginning of the onclicklistener, but that makes the app crash on the second button click. I've even tried clearing the image view with setimagebitmap(null).
Here is the activity that does all the work.
public class MainAvtivity extends Activity
{
ImageView imgView;
Button btnScreenshot;
View rootView;
Bitmap bmap;
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
setContentView(R.layout.main)
imgView = (ImageView)findViewById(R.id.imageView);
btnScreenshot = (Button)findViewById(R.id.btnScreenshot);
rootView = findViewById(android.R.id.content).getRootView();
btnScreenshot.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v){
imgView.setImageBitmap(null);
rootView.destroyDrawinCache();
bmap = takeScreenshot();
setImgView(bmap);
}
}
public Bitmap takeScreenshot()
{
rootView.setDrawingCacheEnabled(true);
return rootView.getDrawingCache();
}
public void setImgView(Bitmap bitmap)
{
imgView.setImageBitmap(bitmap);
}
}