Android examples for Camera:Camera Size
initial Camera Picture Size
import java.util.List; import android.R; import android.content.Context; import android.hardware.Camera.Parameters; import android.hardware.Camera.Size; import android.util.Log; public class Main{ public static void initialCameraPictureSize(Context context, Parameters parameters) {/*from ww w . j a v a2 s . co m*/ // When launching the camera app first time, we will set the picture // size to the first one in the list defined in "arrays.xml" and is also // supported by the driver. List<Size> supported = parameters.getSupportedPictureSizes(); if (supported == null) return; for (String candidate : context.getResources().getStringArray(R.array.pref_camera_picturesize_entryvalues)) { if (setCameraPictureSize(candidate, supported, parameters)) { return; } } } public static boolean setCameraPictureSize(String candidate, List<Size> supported, Parameters parameters) { int index = candidate.indexOf('x'); if (index == -1) return false; int width = Integer.parseInt(candidate.substring(0, index)); int height = Integer.parseInt(candidate.substring(index + 1)); for (Size size : supported) { if (size.width == width && size.height == height) { parameters.setPictureSize(width, height); return true; } } return false; } }