Example usage for android.content.pm ActivityInfo SCREEN_ORIENTATION_UNSPECIFIED

List of usage examples for android.content.pm ActivityInfo SCREEN_ORIENTATION_UNSPECIFIED

Introduction

In this page you can find the example usage for android.content.pm ActivityInfo SCREEN_ORIENTATION_UNSPECIFIED.

Prototype

int SCREEN_ORIENTATION_UNSPECIFIED

To view the source code for android.content.pm ActivityInfo SCREEN_ORIENTATION_UNSPECIFIED.

Click Source Link

Document

Constant corresponding to unspecified in the android.R.attr#screenOrientation attribute.

Usage

From source file:Main.java

public static void UnsetOrientation(Activity context) {
    context.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}

From source file:Main.java

public static void setOrientationUnspecified(Activity context) {
    context.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}

From source file:Main.java

public static void unlockScreenOrientation(final Activity context) {
    boolean portrait = false;
    if (!portrait) {
        context.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    }// w ww.jav  a  2s  . c  om
}

From source file:Main.java

/**
 * Unlock the orientation of the device/*  w  ww  . j a  v a2s. c o m*/
 *
 * @param context the current Activity context
 */
public static void unlockScreenOrientation(Activity context) {
    context.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}

From source file:Main.java

public static void setPortraitOrientation(final Activity activity, final boolean portrait) {
    if (portrait) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else {/*from w  ww  . j  a va  2 s.  c o  m*/
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    }
}

From source file:Main.java

private static int getPlatformOrientation(int o) {
    int platformOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;

    if (o == ORIENTATION_REVERSE_LANDSCAPE && Build.VERSION.SDK_INT >= 9) {
        platformOrientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
    } else if (o == ORIENTATION_REVERSE_PORTRAIT && Build.VERSION.SDK_INT >= 9) {
        platformOrientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
    } else if (o == ORIENTATION_LANDSCAPE || o == ORIENTATION_REVERSE_LANDSCAPE) {
        platformOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
    } else if (o == ORIENTATION_PORTRAIT || o == ORIENTATION_REVERSE_PORTRAIT) {
        platformOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
    }/* w  w  w  .  j  a  va 2 s . c  o m*/

    return platformOrientation;
}

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.  j  av  a2  s  .  c o  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

public static void OrientationFix(Activity context, boolean fixOrient) {
    if (fixOrient) {
        int ori = context.getResources().getConfiguration().orientation;
        if (ori == Configuration.ORIENTATION_LANDSCAPE) {
            context.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else {//from w  w  w  .jav a 2 s  .  co  m
            context.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
    } else {
        context.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    }
}

From source file:Main.java

/**
 * Unlocks specified activity's orientation.
 *
 * @param activity activity/*ww w  . j  av a 2  s  .com*/
 */
public static void unlockOrientation(Activity activity) {
    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}

From source file:Main.java

/**
 * @Thach Feb 21, 2014//  w w  w  .j  a v a2s  .  c  o  m
 * @Desc lock Orientation
 * @param b
 */
@SuppressWarnings("deprecation")
public static void lockOrientation(Activity act, boolean isLock) {
    if (act == null) {
        return;
    }
    if (isLock) {
        Display display = act.getWindowManager().getDefaultDisplay();
        int rotation = display.getRotation();
        int height;
        int width;
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) {
            height = display.getHeight();
            width = display.getWidth();
        } else {
            Point size = new Point();
            display.getSize(size);
            height = size.y;
            width = size.x;
        }
        switch (rotation) {
        case Surface.ROTATION_90:
            if (width > height)
                act.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            else
                act.setRequestedOrientation(9/* reversePortait */);
            break;
        case Surface.ROTATION_180:
            if (height > width)
                act.setRequestedOrientation(9/* reversePortait */);
            else
                act.setRequestedOrientation(8/* reverseLandscape */);
            break;
        case Surface.ROTATION_270:
            if (width > height)
                act.setRequestedOrientation(8/* reverseLandscape */);
            else
                act.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            break;
        default:
            if (height > width)
                act.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            else
                act.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        }
    } else {
        act.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    }
}