Reputation: 97
I am using the countdown timer but when i click back button the timer continues.Can any body tell me how can i stop when i click my phone back button not my application back button.
Sorry for my English.
Thanks in advance.
Upvotes: 1
Views: 2422
Reputation: 293
You need to cancel the timer. Call timer.cancel()
when you press the back button. E.g. in the onPause()
method.
Upvotes: 2
Reputation: 359966
How about overriding the onBackPressed()
method? Something like this (untested):
CountDownTimer mTimer;
// snip...
@Override
public void onBackPressed() {
mTimer.cancel();
}
Upvotes: 2