title: WindowLeaked exception right when thread finishes and calls dialog.dissmiss();
body: <p>I have a tab layout app that needs to download a few files right when it starts, so in the Main.java file in the onCreate method I call:</p>
  
  <pre><code>  myProgressDialog = ProgressDialog.show(Controller.this,
                  "Please wait...", "Doing Extreme Calculations...", true);
      downloadFile(NAME_LOCAL, NAME_SERVER, true);
  </code></pre>
  
  <p>downloadFile is a separate thread it looks likes this:</p>
  
  <pre><code> protected void downloadFile(final String localFilePath, final String remoteFileName, final boolean ASCII) {
  
              // Fire off a thread to do some work that we shouldn't do directly in the UI thread
  
              Thread a = new Thread() {
                  public void run() {
  
  
                      Logger.setLevel(Level.DEBUG); 
  
  
                          try{
                              //create client
                              log.info("Creating Client");
                              ftp = new FileTransferClient();
                              log.info("Setting Remote Host");
                              ftp.setRemoteHost(host);
                              ftp.setUserName(username);
                              ftp.setPassword(password);
                              //connect. . .We hope
                              log.info("Connecting to server " + host);
                              ftp.connect();
                              ftp.getAdvancedFTPSettings().setConnectMode(FTPConnectMode.PASV);
                              if(ASCII){
                              ftp.setContentType(FTPTransferType.ASCII);
                              Log.d("ASCII", "USING ASCII");
                              }else if(!ASCII){
                                  Log.d("BINARY", "USING BINARY");
                                  ftp.setContentType(FTPTransferType.BINARY);
  
                              }
  
                              ftp.downloadFile(cache + localFilePath , remoteFileName);
  
                          }catch (Exception e){
                              e.printStackTrace();
  
                          }
  
  
  
  
  
                      mHandler.post(mUpdateResults);
                      Handler handler=new Handler();
                      handler.post(new Runnable(){public void run(){myProgressDialog.dismiss();}});
  
                  }
              };
              a.start();
  
          }
  </code></pre>
  
  <p>In log cat it starts the download, and it finishes then all the sudden it gives me this:</p>
  
  <pre><code>02-17 17:27:51.175: ERROR/WindowManager(2523): Activity org.IRE.toolbox.Controller has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@46eba2f0 that was originally added here
  
  02-17 17:27:51.175: ERROR/WindowManager(2523): android.view.WindowLeaked: Activity org.IRE.toolbox.Controller has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@46eba2f0 that was originally added here
  </code></pre>
  
  <p>Whats going on?!
  Thanks in advance!</p>