How to use Activity_pause, _resume?

ciginfo

Well-Known Member
Licensed User
Longtime User
Hello,
In my application I use a timer that counts down the seconds until zero.
When I close the application with the home button, the timer stops, and when I open the application again the timer indicates the time it was closing. The timer is stopped.
I would like when application is closed, timer continues to run and when I reopen the appli I find timer running.
I think I have to use Activity_pause or activity_resume but I do not see what I have to put into. Can you help me?
Thank you
 

NJDude

Expert
Licensed User
Longtime User
Assuming you already read what was suggested HERE to answer your question, you should also take a look at how to use a SERVICE you can search the forum for samples or read the Basic4android Beginner's Guide, you can find the links in my signature below.
 
Upvote 0

lagore

Active Member
Licensed User
Longtime User
The other option is to take a note of system time at pause and at resume then subtract them this is how much time has elapsed reduce your timer by this amount and restart timer. If you need something to happen even when your app is paused then you will have to use a service.

Sent from my HTC Desire using Tapatalk 2
 
Upvote 0
Top