Search code examples
androidandroid-layoutscreenshot

How to take a screen shot in android


I want to take a screen shot in android irrespective of the application and without rooting the phone. I have seen into the previous thread link I followed this instructions but they are specific to one application. And we need to change the layout file of every application.

I also came across the link which is a library. One thing which is not clear to me in this is that whether the manifest.xml file should be changed for every application.

Can you please let me know if any other ways are possible? I know this is a security issue but if the application doesnt mind I need to take the screen shots.

Thanks.


Solution

  • if you don't need the status bar (or keyboard) you can do this in your activity:

    View root = findViewById(android.R.id.content);
    root.setDrawingCacheEnabled(true);
    Bitmap bm = Bitmap.createBitmap(root.getDrawingCache());
    root.setDrawingCacheEnabled(false);
    

    Completely untested but it should work.


    After seeing your comment about taking screenshots of other applications I do not believe that what you want is possible without rooting the phone.