0

I have a CountDownTimer that looks like this:

clock = new CountDownTimer(seconds, 1000) { // adjust the milli seconds here
            public void onTick(long millisUntilFinished) {
              timer.setText(String.format(Locale.GERMAN, FORMAT,  
                        TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished) - TimeUnit.MINUTES.toSeconds(
                        TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished))));
            }

            public void onFinish() {
              timer.setText("00");
              end();
            }
        }.start();

And a method:

private void end() {
  Intent intent = new Intent(getApplicationContext(), End.class);

  startActivity(intent);
  finish();
}

But the new activity does not start when the timer runs out, why is this?

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
user8115948
  • 173
  • 1
  • 13

1 Answers1

0

You may try this with your counter

 new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                startActivity(new Intent(getApplicationContext(), End.class));
                finish();
            }
        }, 1000);
Shaifali Rajput
  • 1,279
  • 12
  • 30
Arpit Prajapati
  • 367
  • 2
  • 16