Search code examples
androidscreenshot

how to take android user homepage screenshot programmatically?


I'd like to take the Screenshot of user homepage Could you please guide me how I could do that Currently I am using

LinearLayout linearLayout  = (LinearLayout )findViewById(R.id.layout);
linearLayout.setDrawingCacheEnabled(true);
Bitmap bitmap= linearLayout.getDrawingCache();

Its working for my views but how I can find the Homepage view and take the screenShot of User homepage.


Solution

  • If by Homepage you mean the rootview of the screen then

    getWindow().getDecorView().findViewById(android.R.id.content)
    

    see question 4486034