Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The <a href="http://developer.android.com/reference/android/view/Display.html#getRealSize%28android.graphics.Point%29" rel="nofollow">Display.getRealSize()</a> method was added in API 17, which is Android 4.2. If you try to use it on a device below that, you will get a NoSuchMethodException as the method doesn't exist.</p> <p><a href="http://developer.android.com/reference/android/view/Display.html#getSize%28android.graphics.Point%29" rel="nofollow">Display.getSize()</a> was added in API 13, which is Android 3.2. You want to use the app on Android 3.0, which is API 11.</p> <p>So for older devices, and even current ones (I am yet to hear of a deprecated method actually being removed from Android), you should use <a href="http://developer.android.com/reference/android/view/Display.html#getWidth%28%29" rel="nofollow">getWidth()</a> and <a href="http://developer.android.com/reference/android/view/Display.html#getHeight%28%29" rel="nofollow">getHeight()</a>.</p> <p>Or you could run the code in an if else statement, something like:</p> <pre><code>int currentapiVersion = android.os.Build.VERSION.SDK_INT; if (currentapiVersion &gt;= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1){ //Do something for API 17 only (4.2) //getRealSize() } else if (currentapiVersion &gt;= android.os.Build.VERSION_CODES.HONEYCOMB_MR2){ // Do something for API 13 and above , but below API 17 (API 17 will trigger the above block //getSize() } else{ // do something for phones running an SDK before Android 3.2 (API 13) //getWidth(), getHeight() } </code></pre>
 

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