Android examples for Camera:Camera Preview
Get the preview size that fits within the given width and height and has the largest area
//package com.java2s; import android.hardware.Camera; public class Main { public static Camera.Size getBestPreviewSized(int width, int height, Camera.Parameters parameters) { Camera.Size result = null;//from w ww. ja va 2 s . com for (Camera.Size size : parameters.getSupportedPreviewSizes()) { if (size.width <= width && size.height <= height) { if (result == null) { result = size; } else { int resultArea = result.width * result.height; int newArea = size.width * size.height; if (newArea > resultArea) { result = size; } } } } return (result); } }