App crashing on count and dialog box
<p>i am using following code.</p>

<pre><code>public class MyCount extends CountDownTimer
   {

        public MyCount(long millisInFuture, long countDownInterval) 
        {
            super(millisInFuture, countDownInterval);
        }

        @Override
        public void onFinish() 
        {
             displayAlertForRestart();
        }

        @Override
        public void onTick(long millisUntilFinished) 
        {
            counter.setText("Time Left: " + millisUntilFinished/1000 + " sec");
        }

     }


   public void displayAlertForRestart()
   {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setCancelable(true);
    builder.setMessage("Do you want to Restart?");
    builder.setTitle("Game Over");
    builder.setInverseBackgroundForced(true);
    builder.setPositiveButton("Yes", new DialogInterface.OnClickListener()
    {
      public void onClick(DialogInterface dialog, int which) {

            Intent myIntent = new Intent(context,Level.class);
            startActivity(myIntent);
            dialog.dismiss();
            finish();
      }  
    });
    builder.setNegativeButton("No", new DialogInterface.OnClickListener() {

      public void onClick(DialogInterface dialog, int which) {
        dialog.dismiss();
        finish();

      }
    });
    AlertDialog alert = builder.create();
    alert.show();
   }
</code></pre>

<p>LogCat error: Error at  <code>alert.show();</code></p>

<pre><code>36: E/AndroidRuntime(9829): android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@43cf1e38 is not valid; is your activity running?
</code></pre>
