List of usage examples for android.content.res Configuration SCREENLAYOUT_SIZE_MASK
int SCREENLAYOUT_SIZE_MASK
To view the source code for android.content.res Configuration SCREENLAYOUT_SIZE_MASK.
Click Source Link
From source file:Main.java
/** * Method that returns if the device is a tablet * * @param ctx The current context//from w w w . j a va2 s . c om * @return boolean If device is a table */ public static boolean isTablet(Context ctx) { Configuration configuration = ctx.getResources().getConfiguration(); return (configuration.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; }
From source file:Main.java
/** * Uses the device's screen size to determine if the current device is a tablet or is tablet-sized. * @param context required to provide access to the device configuration information * @return true if the device has a large enough screen to be considered a tablet (for UI purposes). */// ww w. j a v a2s .co m public static boolean isTablet(Context context) { boolean xlarge = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == 4); boolean large = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE); return (xlarge || large); }
From source file:Main.java
public static boolean isTablet(Context context) { return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; }
From source file:Main.java
/** * Checks if the device is a tablet or a phone * * @param activityContext/*from w ww . j a v a 2 s . c o m*/ * The Activity Context. * @return Returns true if the device is a Tablet */ public static boolean isTabletDevice(Context activityContext) { // Verifies if the Generalized Size of the device is XLARGE to be // considered a Tablet boolean xlarge = ((activityContext.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE); // If XLarge, checks if the Generalized Density is at least MDPI // (160dpi) if (xlarge) { DisplayMetrics metrics = new DisplayMetrics(); Activity activity = (Activity) activityContext; activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); // MDPI=160, DEFAULT=160, DENSITY_HIGH=240, DENSITY_MEDIUM=160, // DENSITY_TV=213, DENSITY_XHIGH=320 if (metrics.densityDpi == DisplayMetrics.DENSITY_DEFAULT || metrics.densityDpi == DisplayMetrics.DENSITY_HIGH || metrics.densityDpi == DisplayMetrics.DENSITY_MEDIUM || metrics.densityDpi == DisplayMetrics.DENSITY_TV || metrics.densityDpi == DisplayMetrics.DENSITY_XHIGH) { // Yes, this is a tablet! return true; } } // No, this is not a tablet! return false; }
From source file:Main.java
private static int getNavBarHeight(Context context) { boolean hasMenuKey = Build.VERSION.SDK_INT >= 14 && ViewConfiguration.get(context).hasPermanentMenuKey(); boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); boolean hasNavBar = !hasMenuKey && !hasBackKey; if (hasNavBar) { boolean isPortrait = context.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; boolean isTablet = (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; String key = isPortrait ? "navigation_bar_height" : (isTablet ? "navigation_bar_height_landscape" : null); return key == null ? 0 : getDimenSize(context, key); } else {// w w w .j a va 2 s . c om return 0; } }
From source file:Main.java
/** * Restituisce il tipo di screen su cui gira l'applicazione (small, medium, large, xlarge) * @param context //from ww w.ja v a 2 s . c o m * @return Configuration.SCREENLAYOUT_SIZE_SMALL, Configuration.SCREENLAYOUT_SIZE_NORMAL, * Configuration.SCREENLAYOUT_SIZE_LARGE, Configuration.SCREENLAYOUT_SIZE_XLARGE, * Configuration.SCREENLAYOUT_SIZE_UNDEFINED */ public static int getScreenLayoutType(Context context) { int screenLayout = (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK); return screenLayout; }
From source file:Main.java
/** * Determine if the device is a tablet (i.e. it has a large screen). * /*from w ww.j a v a 2 s .co m*/ * @param context * The calling context. */ public static boolean isTablet(Context context) { return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; }
From source file:net.mm2d.dmsexplorer.SettingsActivity.java
private static boolean isXLargeTablet(Context context) { return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; }
From source file:Main.java
private static boolean isTablet(Context c) { return (c.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; }
From source file:com.noshufou.android.su.AppDetailsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Configuration config = getResources().getConfiguration(); if (config.orientation == Configuration.ORIENTATION_LANDSCAPE && (config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) { finish();// w ww.ja va2 s.co m return; } setContentView(R.layout.activity_app_details); if (savedInstanceState == null) { Fragment fragment = Fragment.instantiate(this, AppDetailsFragment.class.getName(), getIntent().getExtras()); getSupportFragmentManager().beginTransaction().add(R.id.container, fragment).commit(); } }