Android examples for User Interface:Screen Orientation
get Device Current Orientation
//package com.java2s; import android.content.Context; import android.content.res.Configuration; public class Main { public static int getDeviceCurrentOrientation(Context context) { int orientation = context.getResources().getConfiguration().orientation; if (orientation != Configuration.ORIENTATION_LANDSCAPE && orientation != Configuration.ORIENTATION_PORTRAIT) { return Configuration.ORIENTATION_UNDEFINED; }// w ww . j a v a 2s . c om return orientation; } }