Kitesurfer Kitesurfer - 4 years ago 133
Android Question

Is Camera the Front or Back Facing

when i open the Camera like this:

Camera cam =;


Camera cam =;

How can i get information that this is the Front or Back Camera ? Some Devices may have both, some just one.

I need that Information when writing some logic of my code, also for logging.


Answer Source

First of all you may want to look at the reference of Camera class.

Methods getNumberOfCameras (does this device have only one camera or both?) and getCameraInfo ( will provide you with the exact information that you need.

There is an example of using both these methods:

private int findFrontFacingCamera() {
    int cameraId = -1;
    // Search for the front facing camera
    int numberOfCameras = Camera.getNumberOfCameras();
    for (int i = 0; i < numberOfCameras; i++) {
      CameraInfo info = new CameraInfo();
      Camera.getCameraInfo(i, info);
      if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
        Log.d(DEBUG_TAG, "Camera found");
        cameraId = i;
    return cameraId;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download