title: Android 'Unable to add window -- token null is not for an application' exception
body: <p>I get the following Android exception when I try to open a dialog. Can someone please help me understand what is going on and how can I fix this problem?</p>
  
  <pre><code>android.view.WindowManager$BadTokenException: 
    Unable to add window -- token null is not for an application
      at android.view.ViewRoot.setView(ViewRoot.java:509)
      at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
      at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
      at android.app.Dialog.show(Dialog.java:241)
  </code></pre>