camera Facing Back Is In Use - Android android.hardware

Android examples for android.hardware:Back Camera

Description

camera Facing Back Is In Use

Demo Code

import android.hardware.Camera;

public class Main {

  public static Camera cameraFacingBackIsInUse() {
    return cameraIsInUse(Camera.CameraInfo.CAMERA_FACING_BACK);
  }//from  w  w w .jav a2s  .  c o m

  public static Camera cameraIsInUse(int cameraId) {
    Camera camera = null;

    try {
      do {
        if (cameraId < 0 || cameraId >= Camera.getNumberOfCameras()) {
          break;
        }
        camera = Camera.open(cameraId); // attempt to get a Camera instance
      } while (false);

    } catch (Exception e) {
      // Camera is not available (in use or does not exist)
    }

    return camera;// returns null if camera is unavailable
  }

}

Related Tutorials