title: Android wrong screen size
body: <p>I am using this code to get my screen resolution:</p>
  
  <pre><code>//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;
  </code></pre>
  
  <p>But I get a wrong screen size:</p>
  
  <pre><code>06-03 05:25:47.861: I/Screen Size(5267): 1024x552
  </code></pre>
  
  <p>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.</p>
  
  <p>Since I am on android 4.1.1 I cannot use <code>getRealSize()</code> method added in API17. 
  How can I get the correct screen size? </p>
  
  <p><strong>Update:</strong> The density of my panel is not different from 1.0, so it is not a question duplicate. Size should be correct.</p>
  
  <p><strong>Update2:</strong> 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</p>
  
  <pre><code>Method mGetRawW = Display.class.getMethod("getRawWidth");
  Method mGetRawH = Display.class.getMethod("getRawHeight");
  int nW = (Integer)mGetRawW.invoke(dp);
  int nH = (Integer)mGetRawH.invoke(dp);
  </code></pre>
  
  <p>I took it from here: <a href="https://stackoverflow.com/questions/10991194/android-displaymetrics-returns-incorrect-screen-size-in-pixels-on-ics?rq=1">Android DisplayMetrics returns incorrect screen size in pixels on ICS</a></p>