Has Front Camera - Android android.hardware

Android examples for android.hardware:Front Camera

Description

Has Front Camera

Demo Code

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

public class Main {

  public static final int CAMERA_FACING_FRONT = 1;

  public static int HasFrontCamera() {
    int numberOfCameras = Camera.getNumberOfCameras();
    CameraInfo cameraInfo = new CameraInfo();
    for (int i = 0; i < numberOfCameras; i++) {
      Camera.getCameraInfo(i, cameraInfo);
      if (cameraInfo.facing == CAMERA_FACING_FRONT) {
        return i;
      }//from   w w w . j  av a 2 s  .  co m
    }
    return 2;
  }

}

Related Tutorials