![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWYukEiyZa5M4vYc5pK0VGc3n1YhskNx_VakIUhaKFXu0GutCRKgMPTkbOp5FoQ-5cD5DQ66e9Yw_uF8AuGF0E7pmYafQXAQ1jAwlV0FgTp4g2DElxeVzti_DGjB_dVbnncRlIrl23DOLa/s320/nexus10.jpg)
デバイスがタブレットか電話かを判別するメソッドのメモ
private boolean isTabletDevice() { // Verifies if the Generalized Size of the device is XLARGE to be // considered a Tablet boolean xlarge = ((mContext.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == 4); // If XLarge, checks if the Generalized Density is at least MDPI // (160dpi) if (xlarge) { DisplayMetrics metrics = mContext.getResources().getDisplayMetrics(); // 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 == 213/** DisplayMetircs.DENSITY_TV */ || metrics.densityDpi == 320/** DisplayMetrics.DENSITY_XHIGH */ ) { // Yes, this is a tablet! return true; } } // No, this is not a tablet! return false; }
大体これで大丈夫。
(これ前にも書いたっけ?)
0 件のコメント:
コメントを投稿