get Camera Instance and set Orientation - Android android.hardware

Android examples for android.hardware:Camera Orientation

Description

get Camera Instance and set Orientation

Demo Code

import android.hardware.Camera;

public class Main {

  /** A safe way to get an instance of the Camera object. */
  public static Camera getCameraInstance() {
    Camera c = null;//from w w w .  j ava2 s  .c  o m
    try {
      c = Camera.open(); // attempt to get a Camera instance
      c.setDisplayOrientation(90);
    } catch (Exception e) {
      // Camera is not available (in use or does not exist)
    }
    return c; // returns null if camera is unavailable
  }

}

Related Tutorials