title: android.view.WindowManager$BadTokenException: Unable to add window
body: <p>This is the error log:</p>
  
  <pre><code>03-07 11:33:07.474: E/AndroidRuntime(5612): FATAL EXCEPTION: main
  03-07 11:33:07.474: E/AndroidRuntime(5612): android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@45b69850 is not valid; is your activity running?
  03-07 11:33:07.474: E/AndroidRuntime(5612):     at android.view.ViewRootImpl.setView(ViewRootImpl.java:567)
  03-07 11:33:07.474: E/AndroidRuntime(5612):     at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:246)
  03-07 11:33:07.474: E/AndroidRuntime(5612):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
  03-07 11:33:07.474: E/AndroidRuntime(5612):     at android.app.Dialog.show(Dialog.java:281)
  </code></pre>
  
  <p>And I know it is because of bad reference, I get the context through getContext() method(The dialog is not in any activity)</p>
  
  <p>So I can't use XXXActivity.this to get the right context.  so what should I do?</p>