# Keep Timer running even (1) the app screen is off or (2) the app it is closed or (3) in background

**URL:** <https://community.thunkable.com/t/keep-timer-running-even-1-the-app-screen-is-off-or-2-the-app-it-is-closed-or-3-in-background/402018>\
**Category:** Questions about Thunkable X\
**Created:** [January 11, 2020, 9:52am UTC](https://community.thunkable.com/t/keep-timer-running-even-1-the-app-screen-is-off-or-2-the-app-it-is-closed-or-3-in-background/402018 "2020-01-11T09:52:09Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![io.nut.ilie](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/io.nut.ilie/32/51367_2.png) [@io.nut.ilie](https://community.thunkable.com/u/io.nut.ilie)\
**Post date:** [January 11, 2020, 9:52am UTC](https://community.thunkable.com/t/keep-timer-running-even-1-the-app-screen-is-off-or-2-the-app-it-is-closed-or-3-in-background/402018/1 "2020-01-11T09:52:09Z")

</div>

Hello.

A.

I have Timer that runs from a trigger and should do some changes on some specific values (create a visual bar as the times flows).  
But if the screen goes off the timer will do the same.  
So if I want a visual bar that indicates a minute, if the screen turn off, the bar will wait until the screen it is turned on again.  
It is possible to keep the timer running even (1) the app screen is off or (2) the app it is closed or (3) in background?

B.

Do you thing would be an idea to keep the Timer changes but realted to the clock from device and calculate how many minutes, seconds, hours are from the trigger moment?

Thank you.  
Ionut

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 11, 2020, 4:31pm UTC](https://community.thunkable.com/t/keep-timer-running-even-1-the-app-screen-is-off-or-2-the-app-it-is-closed-or-3-in-background/402018/2 "2020-01-11T16:31:26Z")

</div>

Thunkable can’t run processes in the background but I believe there’s a way to still do what you want by comparing the time when the app last ran (in foreground) and the time it was re-opened.

I’ve been working on this (see [this post](http://community.thunkable.com/t/can-i-make-an-app-that-alerts-the-user-of-the-time-to-review/389258/12)) but I got stuck with a loop/wait bug. I think that’s working now so I may be able to figure out a method for this soon.

@mom7667yafy Said they figured out a solution: [Can I make an app that alerts the user of the time to review?](http://community.thunkable.com/t/can-i-make-an-app-that-alerts-the-user-of-the-time-to-review/389258/18)

---

<div class="post-metadata">

**Author:** ![io.nut.ilie](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/io.nut.ilie/32/51367_2.png) [@io.nut.ilie](https://community.thunkable.com/u/io.nut.ilie)\
**Post date:** [January 11, 2020, 4:42pm UTC](https://community.thunkable.com/t/keep-timer-running-even-1-the-app-screen-is-off-or-2-the-app-it-is-closed-or-3-in-background/402018/3 "2020-01-11T16:42:36Z")

</div>

Thank you.  
I saw your post before and I had no idea if there was a solution for you. Also I am glad that somebody has a solution, but it may be a to high level for me.

Yes, the idea with the math and clock maybe something.  
I will try to figure out as a logic first.

Again, thank you!

---

<div class="post-metadata">

**Author:** ![io.nut.ilie](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/io.nut.ilie/32/51367_2.png) [@io.nut.ilie](https://community.thunkable.com/u/io.nut.ilie)\
**Post date:** [January 13, 2020, 3:46pm UTC](https://community.thunkable.com/t/keep-timer-running-even-1-the-app-screen-is-off-or-2-the-app-it-is-closed-or-3-in-background/402018/4 "2020-01-13T15:46:26Z")

</div>

Thank you again.

Would be possible to have (1) a time stamp for start and (2) another one for end and a (3) math formula to know instant how much time was between them?  
Did your original idea was like this? And why it was not doable?

Regards,  
Ionut

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 13, 2020, 7:41pm UTC](https://community.thunkable.com/t/keep-timer-running-even-1-the-app-screen-is-off-or-2-the-app-it-is-closed-or-3-in-background/402018/5 "2020-01-13T19:41:36Z")

</div>

Yes, my idea was similar to this. But several issues including the timer bug I mentioned prevented me from getting it working. It’s a complicated problem and takes some time to implement. I haven’t had the time myself.

---

<div class="post-metadata">

**Author:** ![darren](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/darren/32/69854_2.png) [@darren](https://community.thunkable.com/u/darren)\
**Post date:** [January 13, 2020, 8:01pm UTC](https://community.thunkable.com/t/keep-timer-running-even-1-the-app-screen-is-off-or-2-the-app-it-is-closed-or-3-in-background/402018/6 "2020-01-13T20:01:07Z")

</div>

> [@io.nut.ilie](#):
>
> B.
> 
> Do you thing would be an idea to keep the Timer changes but realted to the clock from device and calculate how many minutes, seconds, hours are from the trigger moment?

I can confirm you can create a timer based on the devices time. Store the start time of the timer in a stored variable when the user starts the timer and then whenever you open the app and the timer is running, you display:

`current device time - stored start time`

The math to calculate the hours, minutes, and seconds is semi-complex. I think I’ll write up a tutorial soon, however, I can’t share the app as it is project for one of my clients.

Good luck!

---

<div class="post-metadata">

**Author:** ![io.nut.ilie](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/io.nut.ilie/32/51367_2.png) [@io.nut.ilie](https://community.thunkable.com/u/io.nut.ilie)\
**Post date:** [January 13, 2020, 8:06pm UTC](https://community.thunkable.com/t/keep-timer-running-even-1-the-app-screen-is-off-or-2-the-app-it-is-closed-or-3-in-background/402018/7 "2020-01-13T20:06:18Z")

</div>

Thank you, @darren!  
I hope you are ok!

---

<div class="post-metadata">

**Author:** ![io.nut.ilie](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/io.nut.ilie/32/51367_2.png) [@io.nut.ilie](https://community.thunkable.com/u/io.nut.ilie)\
**Post date:** [January 13, 2020, 8:06pm UTC](https://community.thunkable.com/t/keep-timer-running-even-1-the-app-screen-is-off-or-2-the-app-it-is-closed-or-3-in-background/402018/8 "2020-01-13T20:06:38Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 11:46am UTC](https://community.thunkable.com/t/keep-timer-running-even-1-the-app-screen-is-off-or-2-the-app-it-is-closed-or-3-in-background/402018/9 "2024-11-08T11:46:03Z")

</div>


