Taking android screen shot of whole screen
<p>My application has a list view in relative layout. Now I need to take a screen shot of the entire layout including all the content available in the list view  and also other contents like button and text view showing in the layout. But my code takes only the visible part of the screen. Here the view is parent layout.</p>

<pre><code>public void screen(){

     View v1 = findViewById(R.id.screenRoot);

    rel.layout(0, 0, rel.getMeasuredWidth(),rel.getMeasuredHeight());    
    View v = v1.getRootView();
    v.setDrawingCacheEnabled(true);

   /* v.measure(MeasureSpec.makeMeasureSpec(w, w), 
            MeasureSpec.makeMeasureSpec(h, h));*/


//        v.layout(0, 0, rel.getWidth(), rel.getHeight());
    v.buildDrawingCache(true);

    System.out.println("rel "+rel.getHeight()+" "+v.getHeight());
    Bitmap b = v.getDrawingCache();  
    v.setDrawingCacheEnabled(false);
    String extr = Environment.getExternalStorageDirectory().toString();
    File myPath = new File(extr, "tiket"+".jpg");
    FileOutputStream fos = null;
    try {
        fos = new FileOutputStream(myPath);
        b.compress(Bitmap.CompressFormat.JPEG, 100, fos);
        fos.flush();
        fos.close();
        MediaStore.Images.Media.insertImage(getContentResolver(), b, "Screen", "screen");
        System.out.println("my path "+myPath+" "+fos);
    }catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    Toast.makeText(getApplicationContext(), "Image Captured Successfully", 0).show();

}
</code></pre>
