Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: How to get the real screen size of the device?
    primarykey
    data
    text
    <p>I have tried different ways to get the screen size of the device, but it always returned me the wrong size (791x480 instead of 854x480), it might be due to the navigation bar. My device is currently running JellyBean 4.1.1.</p> <p>I tried :</p> <pre><code>Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); OpenGLRenderer.widthScreen = size.x; OpenGLRenderer.heightScreen = size.y; </code></pre> <p>And :</p> <pre><code>DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); String resolution = dm.widthPixels + "x" + dm.heightPixels; </code></pre> <p>I'm using the following code to make the app full screen:</p> <pre><code>setContentView(mGLSurfaceView); mGLSurfaceView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); </code></pre> <p>I noticed that in the logcat the right size is returned :</p> <pre><code>01-01 03:05:06.967: I/InputReader(1961): Device reconfigured: id=8, name='cyttsp-spi', surface size is now 480x854, mode is 1 </code></pre> <p>In my AndroidManifest :</p> <pre><code>uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16" </code></pre> <p>I used:</p> <ul> <li><a href="https://stackoverflow.com/questions/8566322/get-the-real-screen-resolution-on-ice-cream-sandwich">Get the real screen resolution on Ice Cream Sandwich</a></li> <li><a href="https://stackoverflow.com/questions/11824193/htc-sensation-real-resolution">HTC Sensation Real Resolution</a></li> <li><a href="https://stackoverflow.com/questions/1016896/android-how-to-get-screen-dimensions">Get screen dimensions in pixels</a></li> </ul> <p>Why am I not able to get the real size (<code>480x854</code>) ? Or how can I use the surface returned by the “Device reconfigured” ?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload