Reputation: 55
Hello I have an Activity that shows a CountDown in a textView (using CountDownTimer), but when I Launch an other activity (config screen) or change screen orientation the countDownTimer is stopped and I want keep this timer running in background, I tried to make a thread with the CountDowntimer inside, but it doesn't work, anyone Knows a way to do that?
Thank You.
Upvotes: 3
Views: 2580
Reputation: 387
You can override onPause method and stop the timer then save last value there. You also need to override onResume and start your timer with last value.
Upvotes: 1
Reputation: 80340
You don't have to make a background thread to have a timer running. Just remember the time when timer was started, then when you need to restart it just show the time base on this remembered time value.
So:
Upvotes: 4