Has Back Camera - Android android.hardware

Android examples for android.hardware:Back Camera

Description

Has Back Camera

Demo Code

import android.hardware.Camera;
import android.hardware.Camera.CameraInfo;

public class Main {

  public static final int CAMERA_FACING_BACK = 0;

  public static int HasBackCamera() {
    int numberOfCameras = Camera.getNumberOfCameras();
    CameraInfo cameraInfo = new CameraInfo();
    for (int i = 0; i < numberOfCameras; i++) {
      Camera.getCameraInfo(i, cameraInfo);
      if (cameraInfo.facing == CAMERA_FACING_BACK) {
        return i;
      }/*from w w  w  .j a v a  2s .c om*/
    }
    return 2;
  }

}

Related Tutorials