WindowManagerBadTokenException unable to add window
<p>I have an error below:</p>

<pre><code>  //TODO tryAgain
private void tryAgain(){
    new AlertDialog.Builder(this)
    .setTitle("Game Over")
    .setMessage("Times Up!")
    .setPositiveButton("Try Again?", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) { 
            dialog.cancel();
            Intent retry = getIntent();
            finish();
            startActivity(retry);
        }
     })
    .setNegativeButton("Back to Menu", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) { 
            dialog.cancel();
            Intent i = new Intent(Stage1_3.this, ShapingColors.class);
            finish();
            startActivity(i);
        }
     })
     .show();   
}   
</code></pre>

<p>Basically what I want to do is cancel the dialog then restart my current activity and the other one I want to go back to menu activity. What am I missing in here? Any help is appreciated.</p>

<p><strong>UPDATE LOGCAT:</strong></p>

<pre><code>   04-27 00:42:44.680: E/AndroidRuntime(330): FATAL EXCEPTION: main
 04-27 00:42:44.680: E/AndroidRuntime(330): android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@40515dc0 is not valid; is your activity running?
 04-27 00:42:44.680: E/AndroidRuntime(330):     at android.view.ViewRoot.setView(ViewRoot.java:527)
 04-27 00:42:44.680: E/AndroidRuntime(330):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
 04-27 00:42:44.680: E/AndroidRuntime(330):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
 04-27 00:42:44.680: E/AndroidRuntime(330):     at android.view.Window$LocalWindowManager.addView(Window.java:424)
 04-27 00:42:44.680: E/AndroidRuntime(330):     at android.app.Dialog.show(Dialog.java:241)
 04-27 00:42:44.680: E/AndroidRuntime(330):     at android.app.AlertDialog$Builder.show(AlertDialog.java:802)
 04-27 00:42:44.680: E/AndroidRuntime(330):     at com.say.shapingcolor.Stage1_3.tryAgain(Stage1_3.java:307)
 04-27 00:42:44.680: E/AndroidRuntime(330):     at com.say.shapingcolor.Stage1_3.access$0(Stage1_3.java:287)
 04-27 00:42:44.680: E/AndroidRuntime(330):     at com.say.shapingcolor.Stage1_3$MyCount.onFinish(Stage1_3.java:319)
 04-27 00:42:44.680: E/AndroidRuntime(330):     at android.os.CountDownTimer$1.handleMessage(CountDownTimer.java:118)
 04-27 00:42:44.680: E/AndroidRuntime(330):     at android.os.Handler.dispatchMessage(Handler.java:99)
 04-27 00:42:44.680: E/AndroidRuntime(330):     at android.os.Looper.loop(Looper.java:123)
 04-27 00:42:44.680: E/AndroidRuntime(330):     at android.app.ActivityThread.main(ActivityThread.java:3683)
 04-27 00:42:44.680: E/AndroidRuntime(330):     at java.lang.reflect.Method.invokeNative(Native Method)
 04-27 00:42:44.680: E/AndroidRuntime(330):     at java.lang.reflect.Method.invoke(Method.java:507)
 04-27 00:42:44.680: E/AndroidRuntime(330):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
 04-27 00:42:44.680: E/AndroidRuntime(330):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
 04-27 00:42:44.680: E/AndroidRuntime(330):     at dalvik.system.NativeStart.main(Native Method)
</code></pre>
