title: Getting a frame from SurfaceView
body: <p>The difficulty I am having now is to take a screenshot of the SurfaceView. Could anyone please help?</p>
  
  <p>My team is doing an Android project where we use MediaCodec to decode the video feed and render the feed onto a Surface.
  The activity implements</p>
  
  <pre><code>SurfaceHolder.Callback
  </code></pre>
  
  <p>Then we created a SurfaceView and add the Callback:</p>
  
  <pre><code>mySurfaveView.getHolder().addCallback(this);
  </code></pre>
  
  <p>Then we start decode the video feed in (we have a method that does the decode)</p>
  
  <pre><code>surfaceChanged(SurfaceHolder holder, int format, int width, int height)
  </code></pre>
  
  <p>The video work fine, now I want to take screenshot of what gets rendered onto the SurfaceView. I have tried several ways to do this, but I didn't succeed. Following are what I have tried:</p>
  
  <ol>
  <li>I have tired getting rootView's drawingcache.</li>
  <li>Tried getting the frame directly from MediaCodec.</li>
  <li>Tried the draw() method to draw on a canvas.</li>
  </ol>
  
  <p>As of now I am tring to create a custom SurfaceView and override the onDraw method there. However, I have never created a custom SurfaceView. Am I on the right direction?</p>
  
  <p>Help please. Thank you!</p>