get Smallest Camera Size - Android Phone

Android examples for Phone:Camera

Description

get Smallest Camera Size

Demo Code


//package com.java2s;

import java.util.Iterator;
import java.util.List;
import android.hardware.Camera.Size;

public class Main {
    public static Size getSmallestSize(List<Size> sizes) {
        Size optimalSize = null;//from  ww w  .j a  v a2  s  .  com
        for (Iterator<Size> iterator = sizes.iterator(); iterator.hasNext();) {
            Size currSize = iterator.next();
            if (optimalSize == null) {
                optimalSize = currSize;
            } else if (optimalSize.height > currSize.height
                    && optimalSize.width > currSize.width) {
                optimalSize = currSize;
            }
        }
        return optimalSize;
    }
}

Related Tutorials