Android examples for Camera:Camera Preview
set Camera Preview Size
//package com.java2s; import java.util.List; import android.annotation.TargetApi; import android.hardware.Camera; import android.os.Build; import android.util.Log; public class Main { static final String TAG = "CameraUtil"; @TargetApi(Build.VERSION_CODES.ECLAIR) public static void setPreviewSize(Camera camera) { if (camera == null) { return; }/*from w ww.j ava 2 s . co m*/ // set optimal preview size Camera.Parameters parameters = camera.getParameters(); Camera.Size current_size = parameters.getPictureSize(); List<Camera.Size> preview_sizes = parameters .getSupportedPreviewSizes(); if (preview_sizes.size() > 0) { Camera.Size best_size = preview_sizes.get(0); for (Camera.Size size : preview_sizes) { if (size.width * size.height > best_size.width * best_size.height) { best_size = size; } } parameters.setPreviewSize(best_size.width, best_size.height); camera.setParameters(parameters); } } }