@TargetApi(Build.VERSION_CODES.HONEYCOMB) private static void choosePreviewSize(Camera.Parameters parms,int width,int height){
  List<Camera.Size> previews=parms.getSupportedPreviewSizes();
  for (  Camera.Size size : previews) {
    if (size.width == width && size.height == height) {
      parms.setPreviewSize(width,height);
      if (Cfg.DEBUG) {
        Check.log(TAG + " (choosePreviewSize), found best preview size!");
      }
      return;
    }
  }
  Camera.Size best=getBestPreviewSize(parms,width,height);
  if (best != null) {
    if (Cfg.DEBUG) {
      Check.log(TAG + " (choosePreviewSize), Camera best preview size for video is " + best.width+ "x"+ best.height);
    }
  }
  if (best != null) {
    Log.w(TAG,"Unable to set preview size to " + width + "x"+ height);
    parms.setPreviewSize(best.width,best.height);
  }
}

@ TargetApi ( Build . VERSION_CODES . HONEYCOMB ) private static void choosePreviewSize ( Camera . Parameters parms , int width , int height ) { List < Camera . Size > previews = parms . getSupportedPreviewSizes ( ) ; for ( Camera . Size size : previews ) { if ( size . width == width && size . height == height ) { parms . setPreviewSize ( width , height ) ; if ( Cfg . DEBUG ) { Check . log ( TAG + " (choosePreviewSize), found best preview size!" ) ; } return ; } } Camera . Size best = getBestPreviewSize ( parms , width , height ) ; if ( best != null ) { if ( Cfg . DEBUG ) { Check . log ( TAG + " (choosePreviewSize), Camera best preview size for video is " + best . width + "x" + best . height ) ; } } if ( best != null ) { Log . w ( TAG , "Unable to set preview size to " + width + "x" + height ) ; parms . setPreviewSize ( best . width , best . height ) ; } }
attempts to find a preview size that matches the provided width and height ( which specify the dimensions of the encoded video ) . if it fails to find a match it just uses the default preview size . < p / > todo : should do a best - fit match .
