Android 平板电脑的判断方法

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;
 

你可能感兴趣的:(android,判断平板电脑)