adjust Camera Orientation - Android android.hardware

Android examples for android.hardware:Camera Orientation

Description

adjust Camera Orientation

Demo Code

import android.content.Context;
import android.content.res.Configuration;
import android.hardware.Camera;

public class Main {

  public static void adjustCamera(Context context, Camera camera) {
    if (context.getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) {
      // parameters.set("orientation","portrait");
      camera.setDisplayOrientation(90);/*from  w  ww. j  a v a2 s .  com*/
    } else {
      // parameters.set("orientation","landscape");
      camera.setDisplayOrientation(0);
    }
  }

}

Related Tutorials