title: How to get screen width and height
body: <p>I tried to use following code to get screen width and height in android app development:</p>
  
  <pre><code>Display display = getWindowManager().getDefaultDisplay(); 
  int screenWidth = display.getWidth();
  int screenHeight = display.getHeight();
  </code></pre>
  
  <p>but I got <strong>NullPointerException</strong> for my <code>display</code>, why? how to get screen width and height then?</p>