title: Activity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@405aeb60 that was originally added here
body: <p>I know there are plenty of answer about this topic... but I am not able to find a solution to my problem. Its simple, an Activity:</p>
  
  <pre><code>public class DialogsActivity extends Activity {
  
  Bundle bundle=new Bundle();
  String token;
  
  @Override
  protected void onResume() {
      // TODO Auto-generated method stub
      super.onResume();
      mostrarDialogo();
  }
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.dialogsactivitylayout);
      bundle=getIntent().getExtras();
      token=bundle.getString("token");
      token=token.replaceAll("\\s+","");
      Log.i("Parse", "Token: "+token);
  
  
  }
  
  private void mostrarDialogo() {
      if(token.equals("nologin")){
          AlertDialog.Builder nologin = new AlertDialog.Builder(DialogsActivity.this);
          nologin.setTitle(R.string.loginstring);
          nologin.setMessage(R.string.nologin);
          nologin.setNegativeButton(R.string.cancel,
                  new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog,
                              int whichButton) {
  
                          dialog.dismiss();
                          finish();
                          return;
                      }
  
                  });
  
  
          nologin.show(); 
      }else if(token.equals("nocon")){
          AlertDialog.Builder nocon = new AlertDialog.Builder(DialogsActivity.this);
          nocon.setTitle(R.string.loginstring);
          nocon.setMessage(R.string.timeout);
          nocon.setNegativeButton(R.string.cancel,
                  new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog,
                              int whichButton) {
  
                          dialog.dismiss();
                          finish();
                          return;
                      }
                  });
          nocon.show();
  
      }else if(token.equals("oklogin")){
  
          AlertDialog.Builder start=new AlertDialog.Builder(DialogsActivity.this);
          start.setTitle(R.string.warn);
          start.setMessage(R.string.service);
          start.setNegativeButton(R.string.accept,
                  new DialogInterface.OnClickListener() {
  
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
  
                          dialog.dismiss();
                          finish();
                          return;
                      }
                  });
          //finish();
          start.show();
      }else if(token!="nocon" &amp;&amp; token!="nologin" &amp;&amp; token!="oklogin"){
          AlertDialog.Builder error=new AlertDialog.Builder(DialogsActivity.this);
          error.setTitle(R.string.unknownerror);
          error.setMessage(R.string.unkerrortext);
          error.setPositiveButton(R.string.accept,
                  new DialogInterface.OnClickListener() {
  
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
  
                          dialog.dismiss();
                          finish();
                          return;
  
                      }
                  });
          error.show();
      }
  
  
  
  }
  
  
  
  }
  </code></pre>
  
  <p>And when the Activity is run, a stacktrace:</p>
  
  <pre><code>05-21 11:46:25.140: E/WindowManager(15737): Activity com.publidirecta.vinceriazafata.DialogsActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@405aeb60 that was originally added here
  05-21 11:46:25.140: E/WindowManager(15737): android.view.WindowLeaked: Activity com.publidirecta.vinceriazafata.DialogsActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@405aeb60 that was originally added here
  05-21 11:46:25.140: E/WindowManager(15737):     at android.view.ViewRoot.&lt;init&gt;(ViewRoot.java:263)
  05-21 11:46:25.140: E/WindowManager(15737):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:171)
  05-21 11:46:25.140: E/WindowManager(15737):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:114)
  05-21 11:46:25.140: E/WindowManager(15737):     at android.view.Window$LocalWindowManager.addView(Window.java:424)
  05-21 11:46:25.140: E/WindowManager(15737):     at android.app.Dialog.show(Dialog.java:241)
  05-21 11:46:25.140: E/WindowManager(15737):     at android.app.AlertDialog$Builder.show(AlertDialog.java:809)
  05-21 11:46:25.140: E/WindowManager(15737):     at com.publidirecta.vinceriazafata.DialogsActivity.mostrarDialogo(DialogsActivity.java:88)
  05-21 11:46:25.140: E/WindowManager(15737):     at com.publidirecta.vinceriazafata.DialogsActivity.onResume(DialogsActivity.java:20)
  05-21 11:46:25.140: E/WindowManager(15737):     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)
  05-21 11:46:25.140: E/WindowManager(15737):     at android.app.Activity.performResume(Activity.java:3832)
  05-21 11:46:25.140: E/WindowManager(15737):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2114)
  05-21 11:46:25.140: E/WindowManager(15737):     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139)
  05-21 11:46:25.140: E/WindowManager(15737):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672)
  05-21 11:46:25.140: E/WindowManager(15737):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
  05-21 11:46:25.140: E/WindowManager(15737):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
  05-21 11:46:25.140: E/WindowManager(15737):     at android.os.Handler.dispatchMessage(Handler.java:99)
  05-21 11:46:25.140: E/WindowManager(15737):     at android.os.Looper.loop(Looper.java:130)
  05-21 11:46:25.140: E/WindowManager(15737):     at android.app.ActivityThread.main(ActivityThread.java:3687)
  05-21 11:46:25.140: E/WindowManager(15737):     at java.lang.reflect.Method.invokeNative(Native Method)
  05-21 11:46:25.140: E/WindowManager(15737):     at java.lang.reflect.Method.invoke(Method.java:507)
  05-21 11:46:25.140: E/WindowManager(15737):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
  05-21 11:46:25.140: E/WindowManager(15737):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
  05-21 11:46:25.140: E/WindowManager(15737):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>The error jumps always on the .show() method, depending of the value of token variable it enters in one if or in another.
  And, as you can see, the dialogs are always dismissed. Any help? Thank you!</p>