Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.pm.ActivityInfo;

import android.os.Build;

public class Main {
    private final static int ORIENTATION_PORTRAIT = 1;
    private final static int ORIENTATION_LANDSCAPE = 2;
    private final static int ORIENTATION_REVERSE_PORTRAIT = 3;
    private final static int ORIENTATION_REVERSE_LANDSCAPE = 4;

    private static int getPlatformOrientation(int o) {
        int platformOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;

        if (o == ORIENTATION_REVERSE_LANDSCAPE && Build.VERSION.SDK_INT >= 9) {
            platformOrientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
        } else if (o == ORIENTATION_REVERSE_PORTRAIT && Build.VERSION.SDK_INT >= 9) {
            platformOrientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
        } else if (o == ORIENTATION_LANDSCAPE || o == ORIENTATION_REVERSE_LANDSCAPE) {
            platformOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
        } else if (o == ORIENTATION_PORTRAIT || o == ORIENTATION_REVERSE_PORTRAIT) {
            platformOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
        }

        return platformOrientation;
    }
}