Android Screen Orientation Check getDisplayOrientation(Context context)

Here you can find the source of getDisplayOrientation(Context context)

Description

get Display Orientation

License

Open Source License

Declaration

public static String getDisplayOrientation(Context context) 

Method Source Code

//package com.java2s;

import android.content.Context;

import android.content.res.Configuration;

public class Main {
    public static String getDisplayOrientation(Context context) {
        String text;/*from  w  w  w .  j  a  v a 2s  .com*/

        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;
    }
}

Related

  1. isDefaultToPortrait(Activity activity)
  2. isLandScape(Context context)
  3. isLandscape(final Context context)
  4. reverseDirectionNow(final float direction)
  5. roundOrientation(int orientation, int orientationHistory)