Android examples for Camera:Camera Size
get Camera Largest Size using Comparator
//package com.java2s; import android.graphics.Point; import android.hardware.Camera; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; public class Main { private static Comparator<Camera.Size> CAMERA_SIZE_COMPARATOR = new Comparator<Camera.Size>() { @Override//from w ww .ja v a 2 s . c o m public int compare(Camera.Size lhs, Camera.Size rhs) { return lhs.width * lhs.height - rhs.width * rhs.height; } }; public static Point getLargestSize(final List<Camera.Size> list) { if (list == null || list.isEmpty()) return null; final ArrayList<Camera.Size> sorted = new ArrayList<>(list); Collections.sort(sorted, CAMERA_SIZE_COMPARATOR); final Camera.Size size = sorted.get(sorted.size() - 1); return new Point(size.width, size.height); } }