Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Based on Robert Dale Johnson III and Helton Isac I came up with this code Hope this is useful </p> <pre><code>public static boolean isTablet(Context context) { TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); if (manager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE) { //Tablet return true; } else { //Mobile return false; } } 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 &amp; Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE); // 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_XHIGH) { // Yes, this is a tablet! return true; } } // No, this is not a tablet! return false; } </code></pre> <p>So in your code make a filter like</p> <pre><code>if(isTabletDevice(Utilities.this) &amp;&amp; isTablet(Utilities.this)){ //Tablet } else { //Phone } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload