For normal use, you can use the DisplayMetrics class and get the “visualized” size, but I want to find out the actual size of the physical screen, which includes the height of the virtual buttons.
In my Galaxy Nexus, the size of the report, regardless of what I tried, is 1196x720, what can I use to get the physical version of 1280x720? The same goes for Nexus 7, Nexus 4, and Nexus 10 devices.
UPDATE This is the last code I'm using now, including the fix:
//Activity A = this; DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager wm = (WindowManager) A.getApplicationContext().getSystemService(Context.WINDOW_SERVICE); Display disp = wm.getDefaultDisplay(); int API_LEVEL = android.os.Build.VERSION.SDK_INT; if (API_LEVEL >= 17) { disp.getRealMetrics(displayMetrics); } else { disp.getMetrics(displayMetrics); } int Width = displayMetrics.widthPixels; int Height = displayMetrics.heightPixels;
source share