title: Why does AlertDialog.Builder(Context context) only accepts Activity as a parameter?
body: <p>In my ongoing learning process (dialog boxes this time), I discovered that this works:</p>
  
  <pre><code>  AlertDialog.Builder builder = new AlertDialog.Builder(this);
  </code></pre>
  
  <p>While the following doesn't work (fails at runtime with WindowManager$BadTokenException):</p>
  
  <pre><code>  AlertDialog.Builder builder = new AlertDialog.Builder(this.getApplicationContext());
  </code></pre>
  
  <p>I don't understand why, because <a href="http://developer.android.com/reference/android/app/AlertDialog.Builder.html#AlertDialog.Builder%28android.content.Context%29" rel="noreferrer">the constructor</a> for AlertDialog.Builder is defined to accept Context as a parameter, not Activity:</p>
  
  <blockquote>
    <p>public AlertDialog.Builder (Context
    context)</p>
    
    <p>Constructor using a context for this
    builder and the AlertDialog it
    creates.</p>
  </blockquote>
  
  <p>What am I missing?</p>