get Front Camera Instance - Android android.hardware

Android examples for android.hardware:Front Camera

Description

get Front Camera Instance

Demo Code

import android.hardware.Camera;

public class Main {

  public static Camera getCameraInstance() {
    Camera c = null;/*  ww  w  .ja  v a  2  s . c o  m*/
    try {
      c = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT); // attempt to get a Camera instance
    } catch (Exception e) {
      // Camera is not available (in use or does not exist)
    }
    return c; // returns null if camera is unavailable
  }

}

Related Tutorials