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測(cè)試獲取出來(lái):Screen inches : 5.147105782031679昧碉。和官方說(shuō)的5.15是對(duì)得上的