开发者

Timer not stopped when i click back button in android

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜