title: Null Pointer Exception when Compressing a Bitmap created from layout
body: <p>I am trying to make an image from the layout and download it.  I am downloading this as a test to make sure the image is correct before I attempt to then convert the bitmap to PDF for download.</p>
  <p>I am receiving a null pointer exception, and I am having issues trying to fix this issue.</p>
  <pre><code> Bitmap bitmap = Bitmap.createBitmap(relativeLayout.getWidth(), relativeLayout.getHeight(), Bitmap.Config.ARGB_8888);
                  Canvas canvas = new Canvas(bitmap);
                  relativeLayout.draw(canvas);
  
                  File filepath = Environment.getExternalStorageDirectory();
                  File dir = new File(filepath.getAbsolutePath() + &quot;/Demo/&quot;);
                  dir.mkdir();
                  File file = new File(dir, System.currentTimeMillis() + &quot;.jpg&quot;);
  
                  try {
                      outputStream = new FileOutputStream(file);
                  } catch (FileNotFoundException e) {
                      e.printStackTrace();
                  }
                  bitmap.compress(Bitmap.CompressFormat.JPEG, 0, outputStream);
  
                  try {
                      outputStream.flush();
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
                  try {
                      outputStream.close();
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
  </code></pre>