I am using this code to get my screen resolution:

```
//View v
Context ctx = v.getContext();
WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;

```

But I get a wrong screen size:

```
06-03 05:25:47.861: I/Screen Size(5267): 1024x552

```

My tablet has a 7" screen with 1024x600 resolution. I guess the missing 48 pixels are the ones used by the system bar, but even hiding it, I get that screen size.

Since I am on android 4.1.1 I cannot use `getRealSize()` method added in API17. 
How can I get the correct screen size? 

**Update:** The density of my panel is not different from 1.0, so it is not a question duplicate. Size should be correct.

**Update2:** The following code worked (it is only for API between 13 and 16). 
It returns 600x1024 so simply make a check on screen orientation to get the proper width/height

```
Method mGetRawW = Display.class.getMethod("getRawWidth");
Method mGetRawH = Display.class.getMethod("getRawHeight");
int nW = (Integer)mGetRawW.invoke(dp);
int nH = (Integer)mGetRawH.invoke(dp);

```

I took it from here: [Android DisplayMetrics returns incorrect screen size in pixels on ICS](https://stackoverflow.com/questions/10991194/android-displaymetrics-returns-incorrect-screen-size-in-pixels-on-ics?rq=1)