window is leaked while hiding a custom dialog
<p>Im using the following code to create a custom dialog.</p>

<pre><code>private void alertLoginSuccess() {
        customDialog.loadigText.setText("Login Successful...");
        Glide.with(getApplicationContext())
                .load(R.drawable.tick)
                .into(customDialog.loadigIcon);
        final Handler handler  = new Handler();
        final Runnable runnable = new Runnable() {
            @Override
            public void run() {
                if (customDialog.isShowing()) {
                    customDialog.hide();
                }
                moveToDashboard(session_token);
            }
        };
        handler.postDelayed(runnable, 1000);
    }
</code></pre>

<p>When the user has logged in successfully, the login successful dialog will appear and then they will be moved towards the dashboard.</p>

<p>But im getting the following error,</p>

<blockquote>
  <p>android.view.WindowLeaked: Activity com.know.LoginActivity has leaked
  window com.android.internal.policy.impl.PhoneWindow$DecorView{41ef86e0
  G.E..... R.....I. 0,0-169,59} that was originally added here
                                                                          at android.view.ViewRootImpl.(ViewRootImpl.java:388)
                                                                          at
  android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:248)
                                                                          at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
                                                                          at android.app.Dialog.show(Dialog.java:286)</p>
</blockquote>

<p>How can I be able to sort this out?</p>