Correct way to capture screenshot
<p>I came across 2 ways to produce screenshot.</p>

<p>I was wondering, </p>

<ol>
<li>What is the different among the two examples? Which is the correct way to do so? </li>
<li>Will <strong>Example 1</strong> possible to have resource/ memory leak problem?</li>
</ol>

<hr>

<p><strong>Example 1</strong></p>

<pre><code>View v = rootView.findViewById(R.id.layout1);
if (v != null) {
    v.setDrawingCacheEnabled(true);
    Bitmap bitmap = v.getDrawingCache();
    canvas.drawBitmap(bitmap, dummyMatrix, null);
    // Possible resource/ memory leak?
}
</code></pre>

<hr>

<p><strong>Example 2</strong></p>

<pre><code>View v = rootView.findViewById(R.id.layout1);
if (v != null) {
    v.buildDrawingCache();
    Bitmap bitmap = v.getDrawingCache();
    canvas.drawBitmap(bitmap, dummyMatrix, null);
    v.destroyDrawingCache();   
}
</code></pre>

<hr>
