1

I have 4 layouts(views) and I wanna get their shortcuts. I use "getDrawingCache()",yeah,I get the pictures,but I found if I wanna get the pictures,I had to make them shown.(I mean they have to be displayed to the user). So Is there any way to get their pictures without displaying them?? Thanks in advance!

Rocky
  • 1,287
  • 3
  • 15
  • 37
  • This will guide you. http://stackoverflow.com/questions/5604125/android-taking-screenshot-of-offscreen-page – blessanm86 Sep 27 '11 at 03:51
  • @blessenm Thanks.But I got errors when I added the code:"measure(...)".I donnot know Why?Is it impossible to get its sreenshortcut if the view is not visible? – Rocky Sep 27 '11 at 05:26

1 Answers1

1

This might work

Window window = getLocalActivityManager().startActivity(Id,intent.addFlags(
        Intent.FLAG_ACTIVITY_CLEAR_TOP));

window.getDecorView().buildDrawingCache();
window.getDecorView().getDrawingCache();

This is what is done to update activities in tab activity. Im not sure but its worth a try.

blessanm86
  • 31,439
  • 14
  • 68
  • 79
  • Thanks.But I got errors when I added the code:"measure(...)".I donnot know Why?Is it impossible to get its sreenshortcut if the view is not visible? – Rocky Sep 27 '11 at 05:29
  • Well you cannot get the drawing cache without actually drawing on the screen. The method we did in the other post i mentioned is that we are accessing the drawing cache before the screen is shown on the screen. But using that method there still a small flicker. btw there is measure... in the code. – blessanm86 Sep 27 '11 at 06:02
  • So If I have 4 LinearLayouts which are inflated from xml file.If I dont draw them on the screen,I get nothing by using getDrawingCache() method,YES?You mentioned the other post is which?Thx – Rocky Sep 27 '11 at 06:32
  • Yes. and the post i mentioned is the one I added as comment to ur question. – blessanm86 Sep 27 '11 at 06:44
  • Btw you might want to try this post. http://www.brighthub.com/mobile/google-android/articles/30676.aspx. They use method by passing a bitmap to the view's dispatchDraw method. – blessanm86 Sep 27 '11 at 06:48