Friday, 15 January 2010

android - How can I tell MyCountDownTimer to quit whenever a certain activity isn't opened? -


The project I am working on is a quiz with a timer on every question. For 30 seconds I saw that if you finish the test before the end of the timer, the timer does not stop running. So if you go ahead in any other examination, the notification that you have not finished the exam, the current activity is popup And will overdrive.

Here MyCountDownTimer Class

  Public MyCountDownTimer (TextView Text Control, Long Million Infra, Long Countdown Interval) {Super (Millis Infouch, Countdown Interval); This.textCounter = textCounter; } @ Override Public Recording ontic (long milliseconds available) {textCounter.setText (String.valueOf (Million Utility / 1000)); } @ Override public empty on finish () {Intent retrieval = new intent (textquarter .Get Context (), retrieval class); If (textCounter.getContext () example test1) {thatTest = 1; RetryIntent.putExtra ("whichTest", whichTest); } If (textCounter.getContext () example test2) {thatTest = 2; RetryIntent.putExtra ("whichTest", whichTest); } If (textCounter.getContext () example test3) {whichTest = 3; RetryIntent.putExtra ("whichTest", whichTest); } If (textCounter.getContext () example test4) {thatTest = 4; RetryIntent.putExtra ("whichTest", whichTest); } If (textCounter.getContext () example test5) {thatTest = 5; RetryIntent.putExtra ("whichTest", whichTest); } If (testCounter.getContext (for example test6) {whichTest = 6; RetryIntent.putExtra ("whichTest", whichTest); } If (textCounter.getContext () example test7) {thatTest = 7; RetryIntent.putExtra ("whichTest", whichTest); } TextCounter.getContext (). StartActivity (try again); }  

Editing: Extra Code if (Text = = empty) {

  myCountDownTimer.onFinish (); }} Else {// String score 7s = integer.txtring (score 7); MyCountDownTimer.cancel (); Intent7 = new intent (Test7.this, UsersAnswers7.class); Intent7.putExtra ("usersAnswers7", usersAnswers7); Intent7.putExtra ("isatOF7", isatOF7); Intent7.putExtra ("Score 7", Score 7); StartActivity (intent7); } 

There is a cancellation method in the countdown timer.

Call and any Finnish () will not be called in the time your user completes the "test" time.


No comments:

Post a Comment