DisplayMetrics dm = new DisplayMetrics();getWindowManager().getDefaultDisplay().getMetrics(dm);double diagonalPixels = Math.sqrt(Math.pow(dm.widthPixels, 2) + Math.pow(dm.heightPixels, 2));double physicalSize = diagonalPixels / (160 * dm.density);boolean isTablet = physicalSize > 7;
???? 或者:
boolean isTablet = (getResources().getConfiguration().screenLayout && Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;?