title: What is the difference between preview size and picture size of android camera
body: <p>In an app which uses the camera, where I need to show the preview of the camera, I can set the preview size by getting all supported preview sizes and find the best one. Should I also set best picture size for the camera? If so what is the difference between preview size and picture size?</p>
  
  <p>And currently I use the below to find the best preview size</p>
  
  <pre><code>int minDiff = Integer.MAX_VALUE;
  for (SizePair sizePair : validPreviewSizes) {
    Size size = sizePair.previewSize();
    int diff =
        Math.abs(size.getWidth() - desiredWidth) + Math.abs(size.getHeight() - desiredHeight);
    if (diff &lt; minDiff) {
      selectedPair = sizePair;
      minDiff = diff;
    }
  }
  </code></pre>
  
  <p>Using this method gives wrong preview sizes in some phones. Can someone suggest a better logic to get best preivew size?</p>