title: Unable to Show Progress Dialog
body: <p>I'm using <code>ProgressDialog</code> to show a <code>loading</code> page in my <code>android app</code> .</p>
  
  <p>My code looks like :</p>
  
  <pre><code>final ProgressDialog dialog = new ProgressDialog(this);
              dialog.setCancelable(false);
              dialog.setMessage("please Wait ...");
              dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
              dialog.setProgressStyle(R.style.progress_dialog_style);
              dialog.show();
              String toastMsg = null;
              LoginService loginService = new LoginService(LoginActivity.this);
              ProfileDetails profileDetails = loginService.checkLogin(mobile_number.getText().toString().trim(), password.getText().toString().trim());
              if(profileDetails != null &amp;&amp; loginService.changeLogin(MainActivity.LOGIN_YES, mobile_number.getText().toString().trim())) {
                  toastMsg = MainActivity.LOGIN_SUCCESSFUL;
              }
    if(profileDetails == null) {
       runOnUiThread(new Runnable() {
             public void run() {
                  dialog.dismiss();
             }
          });
     }
  </code></pre>
  
  <p>and then i perform some <code>DB Operations</code> and get some data</p>
  
  <p>and i use <code>dialog.dismiss()</code>.</p>
  
  <p>If i get data successfully i use <code>startActivity(intent);</code></p>
  
  <p>Here </p>
  
  <p><code>i)</code> if i use <code>dialog.dismiss()</code> when i run the code i am not able to see the Dialog.</p>
  
  <p><code>ii)</code> When i remove the <code>dialog.dimiss()</code> section i am able to see the Dialog but unable to close it.</p>
  
  <p>Please resolve this problem.</p>
  
  <p>Thank You </p>
  
  <p>Log i got is </p>
  
  <pre><code>12-16 00:12:42.325    2146-2172/mycompany.com.weekendmovierating W/EGL_emulation﹕ eglSurfaceAttrib not implemented
  12-16 00:12:42.325    2146-2172/mycompany.com.weekendmovierating W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xa34423e0, error=EGL_SUCCESS
  12-16 00:12:42.632    2146-2172/mycompany.com.weekendmovierating W/EGL_emulation﹕ eglSurfaceAttrib not implemented
  12-16 00:12:42.632    2146-2172/mycompany.com.weekendmovierating W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xa34422e0, error=EGL_SUCCESS
  12-16 00:12:42.804    2146-2160/mycompany.com.weekendmovierating I/art﹕ WaitForGcToComplete blocked for 58.235ms for cause Background
  12-16 00:12:42.937    2146-2156/mycompany.com.weekendmovierating W/art﹕ Suspending all threads took: 38.186ms
  12-16 00:12:42.938    2146-2160/mycompany.com.weekendmovierating W/art﹕ Suspending all threads took: 19.448ms
  12-16 00:12:42.946    2146-2160/mycompany.com.weekendmovierating I/art﹕ Background sticky concurrent mark sweep GC freed 8670(494KB) AllocSpace objects, 5(100KB) LOS objects, 0% free, 5MB/5MB, paused 21.810ms total 130.763ms
  12-16 00:12:43.105    2146-2160/mycompany.com.weekendmovierating W/art﹕ Suspending all threads took: 61.760ms
  12-16 00:12:43.171    2146-2146/mycompany.com.weekendmovierating  I/Choreographer﹕ Skipped 44 frames!  The application may be doing too much work on its main thread.
  12-16 00:12:43.245    2146-2160/mycompany.com.weekendmovierating I/art﹕ Background partial concurrent mark sweep GC freed 1796(126KB) AllocSpace objects, 2(76KB) LOS objects, 39% free, 5MB/9MB, paused 12.887ms total 76.159ms
  12-16 00:12:43.803    2146-2172/mycompany.com.weekendmovierating W/EGL_emulation﹕ eglSurfaceAttrib not implemented
  12-16 00:12:43.803    2146-2172/mycompany.com.weekendmovierating W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xb3fdece0, error=EGL_SUCCESS
  12-16 00:12:44.892    1294-1313/system_process I/ActivityManager﹕ Displayed mycompany.com.weekendmovierating/mycompany.weekendmovierating.activity.SelectLanguageActivity: +2s541ms
  12-16 00:12:45.023    2146-2146/mycompany.com.weekendmovierating I/Choreographer﹕ Skipped 69 frames!  The application may be doing too much work on its main thread.
   12-16 00:12:45.055    1545-6738/com.android.inputmethod.latin E/Surface﹕ getSlotFromBufferLocked: unknown buffer: 0xab7d6dc0
   12-16 00:12:45.082    2146-2172/mycompany.com.weekendmovierating E/Surface﹕ getSlotFromBufferLocked: unknown buffer: 0xab7da1d0
   12-16 00:12:45.093    2146-2172/mycompany.com.weekendmovierating E/Surface﹕ getSlotFromBufferLocked: unknown buffer: 0xab7d8870
  12-16 00:12:45.148    2146-2172/mycompany.com.weekendmovierating E/Surface﹕ getSlotFromBufferLocked: unknown buffer: 0xab7d85d0
  12-16 00:12:45.342    2146-2146/mycompany.com.weekendmovierating E/WindowManager﹕ android.view.WindowLeaked: Activity mycompany.weekendmovierating.activity.LoginActivity has leaked window com.android.internal.policy.PhoneWindow$DecorView{ffa0769 V.E...... R......D 0,0-760,192} that was originally added here
          at android.view.ViewRootImpl.&lt;init&gt;(ViewRootImpl.java:368)
          at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:299)
          at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)
          at android.app.Dialog.show(Dialog.java:319)
          at mycompany.weekendmovierating.activity.LoginActivity.login(LoginActivity.java:87)
          at java.lang.reflect.Method.invoke(Native Method)
          at android.view.View$DeclaredOnClickListener.onClick(View.java:4447)
          at android.view.View.performClick(View.java:5198)
          at android.view.View$PerformClick.run(View.java:21147)
          at android.os.Handler.handleCallback(Handler.java:739)
          at android.os.Handler.dispatchMessage(Handler.java:95)
          at android.os.Looper.loop(Looper.java:148)
          at android.app.ActivityThread.main(ActivityThread.java:5417)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  12-16 00:12:45.371    2146-2156/mycompany.com.weekendmovierating W/art﹕ Suspending all threads took: 25.085ms
   12-16 00:12:45.397    1294-1305/system_process W/WindowManager﹕ Failed looking up window
  java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@aa60cd1 does not exist
          at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8723)
          at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8714)
          at com.android.server.wm.WindowManagerService.removeWindow(WindowManagerService.java:2697)
          at com.android.server.wm.Session.remove(Session.java:187)
          at android.view.IWindowSession$Stub.onTransact(IWindowSession.java:242)
          at com.android.server.wm.Session.onTransact(Session.java:130)
          at android.os.Binder.execTransact(Binder.java:453)
  </code></pre>