Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.Context;

import android.content.res.Configuration;

public class Main {
    public static String getDisplayOrientation(Context context) {
        String text;

        switch (context.getResources().getConfiguration().orientation) {
        case Configuration.ORIENTATION_PORTRAIT:
            text = "portrait";
            break;
        case Configuration.ORIENTATION_LANDSCAPE:
            text = "landscape";
            break;
        case Configuration.ORIENTATION_SQUARE:
            text = "square";
            break;
        default:
            text = null;
        }
        ;

        return text;
    }
}