How to get real screen height and width?
<pre><code>DisplayMetrics metrics = new DisplayMetrics();
this.getWindowManager().getDefaultDisplay().getMetrics(metrics);
screenWidth = metrics.widthPixels;
screenHeight = metrics.heightPixels;
</code></pre>

<p>I use these codes to get the height and width of screen</p>

<p>the screen height on my Nexus7 should be 1280 </p>

<p>but it return 1205...</p>

<p>and my minSdkVersion is level 8</p>

<p>so i can't use these method:</p>

<pre><code>Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int screen_width = size.x;
int screen_height = size.y;
</code></pre>

<p>now, how should i get the correct screen size ?</p>

<p>Edit:</p>

<pre><code>if (Build.VERSION.SDK_INT &gt;= 11) {
        Point size = new Point();
        try {
            this.getWindowManager().getDefaultDisplay().getRealSize(size);
            screenWidth = size.x;
            screenHeight = size.y;
        } catch (NoSuchMethodError e) {
            Log.i("error", "it can't work");
        }

    } else {
        DisplayMetrics metrics = new DisplayMetrics();
        this.getWindowManager().getDefaultDisplay().getMetrics(metrics);
        screenWidth = metrics.widthPixels;
        screenHeight = metrics.heightPixels;
    }
</code></pre>

<p>use it works!</p>
