get Proper Preview Size - Android android.hardware

Android examples for android.hardware:Camera Preview

Description

get Proper Preview Size

Demo Code

import java.util.List;

import android.hardware.Camera;
import android.hardware.Camera.Size;

public class Main {

  public static Camera.Size getProperPreviewSize(Camera.Parameters parametrs) {
    List<Camera.Size> sizesList = parametrs.getSupportedPreviewSizes();

    Size properSize = sizesList.get(0);/*from  w w w . java2s  .c  o  m*/

    if (sizesList.size() > 1) {
      for (int i = 1; i < sizesList.size(); i++) {
        if (sizesList.get(i).width > properSize.width && sizesList.get(i).height > properSize.height) {
          properSize = sizesList.get(i);
        }
      }
    }

    return properSize;
  }

}

Related Tutorials