private void getScreenSizeOfDevice2() {
Point point = new Point();
getWindowManager().getDefaultDisplay().getRealSize(point);
DisplayMetrics dm = getResources().getDisplayMetrics();
double x = Math.pow(point.x/ dm.xdpi, 2);
double y = Math.pow(point.y / dm.ydpi, 2);
double screenInches = Math.sqrt(x + y);
Log.d(TAG, "Screen inches : " + screenInches);
}
小米5测试获取出来:Screen inches : 5.147105782031679。和官方说的5.15是对得上的