DisplayMetrics dm = new DisplayMetrics();
dm = getResources().getDisplayMetrics();
int densityDPI = dm.densityDpi;
1.获取屏幕的真实分辨率
Display display = getWindowManager().getDefaultDisplay();
Point point = new Point();
display.getSize(point);
int width = point.x;
int height = point.y;
2.获取屏幕的真实分辨率(已过时)
int screenWidth = getWindowManager().getDefaultDisplay().getWidth();
int screenHeight = getWindowManager().getDefaultDisplay().getHeight();