Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

CountDownTimer reset.

Hi!

So, I am working on an app in my free time that uses a CountDownTimer and I cannot figure out how to get it to reset. I have tried making it into a method and then calling that in the relevant places but it just seems to keep the same timer running and I cannot figure out why.

If anyone has a solution or a workaround for this then that would be absolutely fantastic!

Hope you guys are all having great days!

-Luke

Post the code you have.

When you say reset, do you mean reset while its counting down? What exactly is the use-case here?

I don't really want to post the code unless I really have to because I am trying to keep this project very secret!

Basically I have a CountDownTimer set up and on each tick it is changing a label. Whenever a button is pressed on the app I then need the CountDownTimer to go back to its initial value.

I hope this was some more information for you.

1 Answer

do you want it to go to the initial value or to pause the timer, and reset it with the left of value?

Every time a button is pressed the timer should jump back to the initial value that it had when the app was first started up.