CountDownTimer won't stop



please i am a beginner at android and i'm trying to add a CountDownTimer to my quizz , well the CountDownTimer works well and when i answer all questions in the time limit i get my results like this : Corrects Answers : 14 Wrong Answers : 16 Score : 14/30


In case i don't catch time i get something like this : Corrects Answers : 14 Wrong Answers : 0 Score : 14/30


Which is correct in my opinions because in that case answers are not wrong but unanswered


But if it happens that i answer all questions before the time finishes .I get the results as i want but the Count doesn't stop and keeps on running until 0 and on 0 it shows that afterward : Corrects Answers : 0 Wrong Answers : 0 Score : 0/30


Here is the code for the timer :


mCountDownTimer = new CountDownTimer(90000, 1000) {



public void onTick(long millisUntilFinished) {
textViewtimer.setText("Seconds remaining: " + millisUntilFinished / 1000);
}

public void onFinish() {
marks = (correct+wrong)-wrong;
Intent resultintent = new Intent(getApplicationContext(),
ResultsActivity.class);
startActivity(resultintent);
mCountDownTimer.cancel();
}
}.start();


Though i'm calling the Intent part somewhere else too to lead me to the score page Please can anyone give me a hint or help?


No comments:

Post a Comment