Here you can find the source of getDisplayOrientation(Context context)
public static String getDisplayOrientation(Context context)
//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; } }