Java tutorial
//package com.java2s; //License from project: Apache License import android.hardware.Camera; import android.view.Surface; public class Main { public static int getRotationAdjustment(int screenRotation) { int degrees = 0; switch (screenRotation) { case Surface.ROTATION_0: degrees = 0; break; case Surface.ROTATION_90: degrees = 90; break; case Surface.ROTATION_180: degrees = 180; break; case Surface.ROTATION_270: degrees = 270; break; } int cameraOrientation = getCameraOrientation(); return (cameraOrientation - degrees + 360) % 360; } public static int getCameraOrientation() { Camera.CameraInfo cameraInfo = getCameraInfo(); return cameraInfo.orientation; } private static Camera.CameraInfo getCameraInfo() { Camera.CameraInfo info = new Camera.CameraInfo(); for (int i = 0; i < Camera.getNumberOfCameras(); i++) { Camera.getCameraInfo(i, info); if (info.facing == Camera.CameraInfo.CAMERA_FACING_BACK) { break; } } return info; } }