Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.app.Activity;

import android.hardware.Camera;
import android.hardware.Camera.CameraInfo;

import android.os.Build.VERSION;

public class Main {
    public static int determineDisplayOrientation(Activity activity, int defaultCameraId) {
        if (VERSION.SDK_INT <= 8) {
            return 0;
        }
        CameraInfo cameraInfo = new CameraInfo();
        Camera.getCameraInfo(defaultCameraId, cameraInfo);
        int degrees = getRotationAngle(activity);
        if (cameraInfo.facing == 1) {
            return (360 - ((cameraInfo.orientation + degrees) % 360)) % 360;
        }
        return ((cameraInfo.orientation - degrees) + 360) % 360;
    }

    public static int getRotationAngle(Activity activity) {
        switch (activity.getWindowManager().getDefaultDisplay().getRotation()) {
        default:
            return 0;
        }
    }

    public static int getRotationAngle(int rotation) {
        switch (rotation) {
        default:
            return 0;
        }
    }
}