Returns a list of available camera preview sizes - Android android.hardware

Android examples for android.hardware:Camera Preview

Description

Returns a list of available camera preview sizes

Demo Code

import android.graphics.Bitmap;
import android.hardware.Camera;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.List;

public class Main{

    /** Returns a list of available camera preview sizes, or null if the Android API to get the sizes is not available.
     *//*from w  w  w.ja  v a2  s  .com*/
    public static List<Camera.Size> previewSizesForCameraParameters(
            Camera.Parameters params) {
        try {
            Method m = params.getClass().getMethod(
                    "getSupportedPreviewSizes");
            return (List<Camera.Size>) m.invoke(params);
        } catch (Exception ex) {
            return null;
        }
    }

}

Related Tutorials