Example usage for android.content.res Configuration SCREENLAYOUT_SIZE_MASK

List of usage examples for android.content.res Configuration SCREENLAYOUT_SIZE_MASK

Introduction

In this page you can find the example usage for android.content.res Configuration SCREENLAYOUT_SIZE_MASK.

Prototype

int SCREENLAYOUT_SIZE_MASK

To view the source code for android.content.res Configuration SCREENLAYOUT_SIZE_MASK.

Click Source Link

Document

Constant for #screenLayout : bits that encode the size.

Usage

From source file:Main.java

public static int getScreenSize(Context context) {
    return context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
}

From source file:Main.java

public static boolean isTablet(Context context) {
    int screenLayoutMask = context.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK;
    return (screenLayoutMask == 4)// Configuration.SCREENLAYOUT_SIZE_XLARGE = 4
            || (screenLayoutMask == Configuration.SCREENLAYOUT_SIZE_LARGE);
}

From source file:Main.java

public static boolean isTablet(Context context) {
    int s = context.getApplicationContext().getResources().getConfiguration().screenLayout;
    s &= Configuration.SCREENLAYOUT_SIZE_MASK;
    return s >= Configuration.SCREENLAYOUT_SIZE_LARGE;
}

From source file:Main.java

public static boolean isTablet(Context context) {
    int screenLayout = context.getResources().getConfiguration().screenLayout;
    return (screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
}

From source file:Main.java

public static boolean isXLargeDevice(Activity ctx) {
    int lt = (ctx.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK);
    return lt == Configuration.SCREENLAYOUT_SIZE_XLARGE;
}

From source file:Main.java

public static boolean isPhone(Activity context) {
    return ((context.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) < Configuration.SCREENLAYOUT_SIZE_LARGE)
            || getPhysicalSize(context) < 6;
}

From source file:Main.java

public static boolean isTablet(Context context) {
    Configuration configuration = context.getResources().getConfiguration();
    return (configuration.screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
}

From source file:Main.java

/**
 * returns true if screen is Xlarge so restricts orientation based on that
 * @param context//  w  w  w . j a  v  a  2  s . c  o  m
 * @return
 */
public static boolean isScreenXLarge(Context context) {
    return (context.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) >= (Configuration.SCREENLAYOUT_SIZE_LARGE);
}

From source file:Main.java

private static boolean isEnoughSpace(Configuration configuration) {
    if (configuration == null) {
        return false;
    }/*  w w  w . j  a v  a 2 s .c o m*/
    if (configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
        return true;
    }
    int sizeMask = configuration.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
    boolean smallScreen = sizeMask == Configuration.SCREENLAYOUT_SIZE_SMALL
            || sizeMask == Configuration.SCREENLAYOUT_SIZE_NORMAL;
    return !smallScreen;
}

From source file:Main.java

/**
 * Checks if current device is tablet.//from  w w  w.  ja  v a  2 s.  c  o m
 * 
 * @param content
 * @return boolean
 */
@SuppressLint("InlinedApi")
public static boolean isTablet(Context content) {
    boolean large = ((content.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE);
    boolean xlarge = ((content.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE);
    return (large || xlarge);
}