android taking screenshot of offscreen page

Krishnabhadra picture Krishnabhadra · Apr 9, 2011 · Viewed 9.6k times · Source

I am working on an android application. I have an activity, say A, which fills the entire screen with views..On a button click in A I want to start another activity, say B, which also has some views and controls. I want activity B to be offscreen , and want to take the screenshot of B from A . Is it possible?

Note: I am successful in taking the screenshot of page A by saving the drawing cache in to a bitmap, but struggling to take the offscreen page's screenshot.

Answer

Kandha picture Kandha · Apr 16, 2011

Yes it is possible...You should extend ActivityGroup in Activity 'A'. Then do this in your button click event...

 View view =getLocalActivityManager().startActivity("B",new Intent(this,B.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();

then convert that view as bitmap...

I think this is helpful for you...