I am using the countdown timer but when i click back button the timer continues.Can any body tell 开发者_JAVA技巧me how can i stop when i click my phone back button not my application back button.
Sorry for my English.
Thanks in advance.
How about overriding the onBackPressed()
method? Something like this (untested):
CountDownTimer mTimer;
// snip...
@Override
public void onBackPressed() {
mTimer.cancel();
}
You need to cancel the timer. Call timer.cancel()
when you press the back button. E.g. in the onPause()
method.
精彩评论