List of usage examples for android.content.res Configuration ORIENTATION_LANDSCAPE
int ORIENTATION_LANDSCAPE
To view the source code for android.content.res Configuration ORIENTATION_LANDSCAPE.
Click Source Link
From source file:Main.java
public static int getScreenOrientation(Activity activity) { Display getOrient = activity.getWindowManager().getDefaultDisplay(); int orientation = Configuration.ORIENTATION_UNDEFINED; if (getOrient.getWidth() == getOrient.getHeight()) { orientation = Configuration.ORIENTATION_SQUARE; } else {//from w w w.jav a 2s . c om if (getOrient.getWidth() < getOrient.getHeight()) { orientation = Configuration.ORIENTATION_PORTRAIT; } else { orientation = Configuration.ORIENTATION_LANDSCAPE; } } return orientation; }
From source file:Main.java
/** * Method getDeviceScreenWidth(), It's used for checking the screen's with * and To develop the functionality of horizontal direction or vertical * direction, we can used this for seperating the raised issues * /*w w w . jav a2s . c o m*/ * @return Integer Type. */ public static int getDeviceScreenWidth(Context context) { int width; WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { width = wm.getDefaultDisplay().getHeight(); } else { width = wm.getDefaultDisplay().getWidth(); } return width; }
From source file:Main.java
public static void lockOrientation(Activity activity) { Display display = ((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int rotation = display.getRotation(); int tempOrientation = activity.getResources().getConfiguration().orientation; int orientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; switch (tempOrientation) { case Configuration.ORIENTATION_LANDSCAPE: if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; else//from w w w. ja va 2 s . co m orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; break; case Configuration.ORIENTATION_PORTRAIT: if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_270) orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; else orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; } activity.setRequestedOrientation(orientation); }
From source file:Main.java
/** * Method getDeviceScreenHeight(). It's used for checking the screen's with * and To develop the functionality of horizontal direction or vertical * direction, we can used this for seperating the raised issues * /* www. j av a 2 s. co m*/ * @return Integer Type. */ public static int getDeviceScreenHeight(Context context) { int height; WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { height = wm.getDefaultDisplay().getWidth(); } else { height = wm.getDefaultDisplay().getHeight(); } return height; }
From source file:Main.java
public static int getScreenOrientation(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); int orientation = Configuration.ORIENTATION_UNDEFINED; if (display.getWidth() == display.getHeight()) { orientation = Configuration.ORIENTATION_SQUARE; } else {//from w w w . ja v a2 s . co m if (display.getWidth() < display.getHeight()) { orientation = Configuration.ORIENTATION_PORTRAIT; } else { orientation = Configuration.ORIENTATION_LANDSCAPE; } } return orientation; }
From source file:Main.java
public static int convertConfigToTiOrientationMode(int configOrientationMode) { switch (configOrientationMode) { case Configuration.ORIENTATION_PORTRAIT: return ORIENTATION_PORTRAIT; case Configuration.ORIENTATION_LANDSCAPE: return ORIENTATION_LANDSCAPE; case Configuration.ORIENTATION_SQUARE: return ORIENTATION_SQUARE; default://from ww w . j a v a2 s.c om return ORIENTATION_UNKNOWN; } }
From source file:Main.java
@TargetApi(13) public static int getColumnCount(Context context) { if (!API_13) { int screenSize = context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; if (screenSize == Configuration.SCREENLAYOUT_SIZE_SMALL) return 1; int orientation = context.getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_LANDSCAPE) return 2; } else {// w w w .j av a 2 s . c o m int screenWidthDp = context.getResources().getConfiguration().screenWidthDp; // if (screenWidthDp > 820) return 4; if (screenWidthDp >= 720) return 3; if (screenWidthDp >= 480) return 2; } return 1; }
From source file:Main.java
/** * Untested, taken from stack-overflow.//from ww w . j ava2s . com * * @param activity */ public static void disableScreenOrientationChange(Activity activity) { final int orientation = activity.getResources().getConfiguration().orientation; final int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) { if (orientation == Configuration.ORIENTATION_PORTRAIT) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } } else if (rotation == Surface.ROTATION_180 || rotation == Surface.ROTATION_270) { if (orientation == Configuration.ORIENTATION_PORTRAIT) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); } } }
From source file:Main.java
public static int getOrientation(Context context) { WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display getOrient = windowManager.getDefaultDisplay(); int orientation = Configuration.ORIENTATION_UNDEFINED; if (getOrient.getWidth() == getOrient.getHeight()) { orientation = Configuration.ORIENTATION_SQUARE; } else {/* w w w. ja v a 2 s . co m*/ if (getOrient.getWidth() < getOrient.getHeight()) { orientation = Configuration.ORIENTATION_PORTRAIT; } else { orientation = Configuration.ORIENTATION_LANDSCAPE; } } return orientation; }
From source file:Main.java
public static final boolean isLandscape(Context context) { return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; }