Class cast exception while using WindowManager in Android
<p>My code to get the screen height dynamically:</p>

<pre><code>Display display = ((Activity) getContext()).getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;
</code></pre>

<p>Error:
    Error: java.lang.ClassCastException: android.app.Application
Complete log cat: <a href="http://pastebin.com/8zUNFUYn" rel="nofollow">http://pastebin.com/8zUNFUYn</a></p>

<p>Edit:
Changed code to this:</p>

<pre><code>Display display =  (activity).getWindowManager().getDefaultDisplay();

        Point size = new Point();
        display.getSize(size);
        int width = size.x;
        int height = size.y;
</code></pre>

<p>Worked but, gave a new error that is display.getSize(size) is not a method. Is that API depreceated?</p>
