Java tutorial
//package com.java2s; //License from project: Open Source License import android.hardware.Camera; public class Main { public static int getDisplayOrientation(int cameraId) { Camera.CameraInfo info = new Camera.CameraInfo(); Camera.getCameraInfo(cameraId, info); int result; if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { result = (info.orientation) % 360; result = (360 - result) % 360; // compensate the mirror } else { // back-facing result = (info.orientation + 360) % 360; } return result; } }