title: take screenshot of entire screen programmatically
body: <p>I have this code for take screenshot of current view, a fragment that lives into an activity, where the activity has only a background.</p>
  
  <pre><code>private File captureScreen() {
  
      Bitmap screenshot = null;
      try {
  
          if (view != null) {
  
              screenshot = Bitmap.createBitmap(view.getMeasuredWidth(),
                      view.getMeasuredHeight(), Config.ARGB_8888);
              Canvas canvas = new Canvas(screenshot);
              view.draw(canvas);
              // save pics
              File cache_dir = Environment.getExternalStorageDirectory();
              ByteArrayOutputStream bytes = new ByteArrayOutputStream();
              screenshot.compress(Bitmap.CompressFormat.PNG, 90, bytes);
              File f = new File(cache_dir + File.separator + "screen.png");
              f.createNewFile();
              FileOutputStream fo = new FileOutputStream(f);
              fo.write(bytes.toByteArray());
              fo.close();
              return f;
          }
      } catch (Exception e) {
          // TODO
      }
      return null;
  }
  </code></pre>
  
  <p>but bitmap saved is not exactly what i'm expecting.
  Screenshot take only fragment elements, but not activity background. How can i include it into screenshot?</p>