title: Login Activity has leaked window
body: <p>I know that that exception comes out of a dialog that wasn't dismissed. </p>
  
  <p>Here's the activity that crashes the application (<strong>The following code is the main part of the activity, the others are just little functions (with no dialogs)</strong>:</p>
  
  <pre><code> public void facebookLogin()
  {
      shareAppPreferences = new AppPreferences(getApplicationContext());
       facebook =  new Facebook("something");//((GlobalVars)getApplicationContext()).facebook;
  
       String access_token = shareAppPreferences.getAccessToken();
       Long expires = shareAppPreferences.getAccessExpires();
       Log.d("MyTag","token:" +access_token);
       if(access_token != null) {
           facebook.setAccessToken(access_token);
       }
       if(expires != 0) {
           facebook.setAccessExpires(expires);
       }
       /*
        * Only call authorize if the access_token has expired.
        */
       if(!facebook.isSessionValid()) {
           Log.d("MyTag","In Authorize");
            facebook.authorize(this, new String[] {"publish_stream", "email"}, Facebook.FORCE_DIALOG_AUTH, new DialogListener() {
                public void onComplete(Bundle values) {
  
                    shareAppPreferences.saveAccessToken(facebook.getAccessToken());
                    Log.d("MyTag","face token: " +facebook.getAccessToken());
                    shareAppPreferences.saveAccessExpires(facebook.getAccessExpires());
  
                }
  
                public void onFacebookError(FacebookError e) {
                  Toast.makeText(getApplicationContext(), "onFacebookError", Toast.LENGTH_SHORT).show();
              }
  
              public void onError(DialogError e) {
                  Toast.makeText(getApplicationContext(), "onError", Toast.LENGTH_SHORT).show();
              }
              public void onCancel() {
  
            }
            });
       }
       new AccessKeyTask().execute("someURL");
       Intent intent = new Intent(this,MainActivity.class);
       Log.d("MyTag", "starting activity");
       startActivity(intent);
  
  }
  </code></pre>
  
  <p>Here's the Logcat exception part:</p>
  
  <pre><code>    11-22 18:32:06.484: I/MapActivity(19687): Handling network change notification:CONNECTED
  11-22 18:32:06.488: E/MapActivity(19687): Couldn't get connection factory client
  11-22 18:32:06.707: E/WindowManager(19687): Activity com.inturnex.allaround.Login has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@4055d560 that was originally added here
  11-22 18:32:06.707: E/WindowManager(19687): android.view.WindowLeaked: Activity com.inturnex.allaround.Login has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@4055d560 that was originally added here
  11-22 18:32:06.707: E/WindowManager(19687):     at android.view.ViewRoot.&lt;init&gt;(ViewRoot.java:260)
  11-22 18:32:06.707: E/WindowManager(19687):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
  11-22 18:32:06.707: E/WindowManager(19687):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
  11-22 18:32:06.707: E/WindowManager(19687):     at android.view.Window$LocalWindowManager.addView(Window.java:424)
  11-22 18:32:06.707: E/WindowManager(19687):     at android.app.Dialog.show(Dialog.java:241)
  11-22 18:32:06.707: E/WindowManager(19687):     at com.facebook.android.Facebook.dialog(Facebook.java:839)
  11-22 18:32:06.707: E/WindowManager(19687):     at com.facebook.android.Facebook.startDialogAuth(Facebook.java:368)
  11-22 18:32:06.707: E/WindowManager(19687):     at com.facebook.android.Facebook.authorize(Facebook.java:231)
  11-22 18:32:06.707: E/WindowManager(19687):     at com.inturnex.allaround.Login.facebookLogin(Login.java:147)
  11-22 18:32:06.707: E/WindowManager(19687):     at com.inturnex.allaround.Login.onCreate(Login.java:55)
  11-22 18:32:06.707: E/WindowManager(19687):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  11-22 18:32:06.707: E/WindowManager(19687):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1628)
  11-22 18:32:06.707: E/WindowManager(19687):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1680)
  11-22 18:32:06.707: E/WindowManager(19687):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
  11-22 18:32:06.707: E/WindowManager(19687):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
  11-22 18:32:06.707: E/WindowManager(19687):     at android.os.Handler.dispatchMessage(Handler.java:99)
  11-22 18:32:06.707: E/WindowManager(19687):     at android.os.Looper.loop(Looper.java:130)
  11-22 18:32:06.707: E/WindowManager(19687):     at android.app.ActivityThread.main(ActivityThread.java:3703)
  11-22 18:32:06.707: E/WindowManager(19687):     at java.lang.reflect.Method.invokeNative(Native Method)
  11-22 18:32:06.707: E/WindowManager(19687):     at java.lang.reflect.Method.invoke(Method.java:507)
  11-22 18:32:06.707: E/WindowManager(19687):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
  11-22 18:32:06.707: E/WindowManager(19687):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
  11-22 18:32:06.707: E/WindowManager(19687):     at dalvik.system.NativeStart.main(Native Method)
  11-22 18:32:07.402: D/PhoneWindow(19687): couldn't save which view has focus because the focused view android.widget.RelativeLayout@40593b28 has no id.
  11-22 18:32:07.402: D/PhoneWindow(19687): couldn't save which view has focus because the focused view android.widget.RelativeLayout@40593b28 has no id.
  </code></pre>