Java tutorial
//package com.java2s; import android.content.Context; import android.content.res.Configuration; public class Main { private static Context sCurrentContext; /** * <pre> * Determine whether current orientation is portrait. * </pre> */ public static boolean isPortraitDisplay() { return getCurrentContext().getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; } /** * <pre> * Get current context of the app. This method resolves the inconvenience of Android which requires context for most of its API. * If no activity is resumed, this method returns application context. Otherwise, this method returns last resumed activity. * </pre> */ public static Context getCurrentContext() { return sCurrentContext; } }