Reputation: 475
I want the AlertDialog to show up once the CountDownTimer finishes but I get an error when I try to do it. Does anyone have a solution or a better way of doing it?
{
new CountDownTimer(60000, 1000) {
public void onTick(long millisUntilFinished) {
mTextField.setText(":" + millisUntilFinished / 1000);
}
public void onFinish() {
mTextField.setText("GAME OVER");
mTextField.setTextSize(50);
AlertDialog.Builder ADB = new AlertDialog.Builder(getApplicationContext());
ADB.setTitle("GAME OVER")
.setMessage(R.string.app_name)
.setNeutralButton("PRESS BACK AND START GAME TO PLAY AGAIN", null)
.show();
}
}.start();
}
Upvotes: 1
Views: 1041
Reputation: 2393
try this code
new Thread()
{
public void run()
{
sleep(3000);
AlertDialog.Builder successfullyLogin = new Builder(LWM.this);
successfullyLogin.setCancelable(false);
successfullyLogin.setMessage("Successfully Login !").show();
}
};
Upvotes: 1
Reputation: 7605
Actually your code perfect i run it but replace
AlertDialog.Builder ADB = new AlertDialog.Builder(getApplicationContext());
by where replace Game by your activityname
AlertDialog.Builder ADB = new AlertDialog.Builder(Game.this);
Upvotes: 3