Java tutorial
//package com.java2s; //License from project: Open Source License import android.hardware.Camera; import android.util.Log; import java.util.List; public class Main { private static final String TAG = "RxCamera.CameraUtil"; public static int[] findClosestFpsRange(Camera camera, int minFrameRate, int maxFrameRate) { minFrameRate *= 1000; maxFrameRate *= 1000; Camera.Parameters parameters = camera.getParameters(); int minIndex = 0; int minDiff = Integer.MAX_VALUE; List<int[]> rangeList = parameters.getSupportedPreviewFpsRange(); Log.d(TAG, "support preview fps range list: " + dumpFpsRangeList(rangeList)); for (int i = 0; i < rangeList.size(); i++) { int[] fpsRange = rangeList.get(i); if (fpsRange.length != 2) { continue; } int minFps = fpsRange[0] / 1000; int maxFps = fpsRange[1] / 1000; int diff = Math.abs(minFps - minFrameRate) + Math.abs(maxFps - maxFrameRate); if (diff < minDiff) { minDiff = diff; minIndex = i; } } int[] result = rangeList.get(minIndex); return result; } private static String dumpFpsRangeList(List<int[]> rangeList) { String result = ""; for (int[] range : rangeList) { if (range.length != 2) { continue; } result += "(" + range[0] + "," + range[1] + ") "; } return result; } }