title: Taking screen shot of a SurfaceView in android
body: <p>I am using following method to taking screen shot of a particular view which is a SurfaceView.</p>
  
  <pre><code>public void takeScreenShot(View surface_view){
  
      // create bitmap screen capture
      Bitmap bitmap;
      View v1 = surface_view;
      v1.setDrawingCacheEnabled(true);
      bitmap = Bitmap.createBitmap(v1.getDrawingCache());
      v1.setDrawingCacheEnabled(false);
  
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      bitmap.compress(CompressFormat.PNG, 0, bos);
      byte[] imageData = bos.toByteArray();
  
  }
  </code></pre>
  
  <p>the problem is its giving me the whole activity screen image. But I need to take screen shot of the particular view. I tried other ways but those give me a black screen as screen shot, some posts says that it requires rooted device.
  Can any one help me please. I'm in need of this solution. Help me....</p>