Devices with Ice Cream Sandwich can use on-screen soft keys, and this means that some of the screen estate is taken by these keys. I need to get the real screen resolution, and not the resolution minus the space taken up by the soft keys.
I've tried the following, but neither works:
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
Log.d("SCREEN RES", "Width: " + width + ". Height: " + height);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
height = metrics.heightPixels;
width = metrics.widthPixels;
Log.d("SCREEN RES", "Width: " + width + ". Height: " + height);
Here's the output:
12-19 20:18:42.012: D/SCREEN RES(20752): Width: 1196. Height: 720
12-19 20:18:42.012: D/SCREEN RES(20752): Width: 1196. Height: 720
The real screen resolution is 1280 x 720 pixels, not 1196 x 720 pixels.
Any ideas?
Edit
I'm using the following code to make the app full screen:
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);