Returns a list of available camera preview sizes, or null if the Android API to get the sizes is not available. - Android Camera

Android examples for Camera:Camera Preview

Description

Returns a list of available camera preview sizes, or null if the Android API to get the sizes is not available.

Demo Code


//package com.java2s;
import java.lang.reflect.Method;

import java.util.List;

import android.hardware.Camera;

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 www  .ja  v  a  2s. co  m*/
    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