What is the better way of creating Windowmanager instance android
<p>I found the following two ways of creating WindowManager instance</p>

<pre><code>WindowManager w = activity.getWindowManager();
</code></pre>

<p>and</p>

<pre><code>WindowManager windowManager = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
</code></pre>

<p>but in Motorola Milestone if I use the first approach of creating WindowManager then I am not getting accurate width of my device</p>

<p>to get width i have used <code>windowManager.getDefaultDisplay().getWidth();</code></p>

<p>But If I use the second approach then I am getting accurate width of device.</p>

<p>I have tested in <code>motorla milestone</code></p>

<ul>
<li>What is the difference between these two types of WindowManager.</li>
<li>Why i am getting different results.</li>
<li>What is the better way of creating WindowManager instance?</li>
</ul>
