# Help build a timer that works when the screen is locked

**URL:** <https://community.thunkable.com/t/help-build-a-timer-that-works-when-the-screen-is-locked/1238064>\
**Category:** Questions about Thunkable X\
**Created:** [April 22, 2021, 7:50am UTC](https://community.thunkable.com/t/help-build-a-timer-that-works-when-the-screen-is-locked/1238064 "2021-04-22T07:50:12Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Balanced\_Kitchen](https://avatars.discourse-cdn.com/v4/letter/b/839c29/32.png) [@Balanced\_Kitchen](https://community.thunkable.com/u/Balanced_Kitchen)\
**Post date:** [April 22, 2021, 7:50am UTC](https://community.thunkable.com/t/help-build-a-timer-that-works-when-the-screen-is-locked/1238064/1 "2021-04-22T07:50:12Z")

</div>

The timer is ready and working. But every time the user locks the screen the timer stops. Is there a way for the timer to continue working when the screen is locked?

---

<div class="post-metadata">

**Author:** ![tony.ycy.program](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tony.ycy.program/32/100153_2.png) [@tony.ycy.program](https://community.thunkable.com/u/tony.ycy.program)\
**Post date:** [April 22, 2021, 9:43am UTC](https://community.thunkable.com/t/help-build-a-timer-that-works-when-the-screen-is-locked/1238064/2 "2021-04-22T09:43:59Z")

</div>

The thunkable timer does not seem to work in the background！ 😭  
But [ai2](http://ai2.appinventor.mit.edu)  
can.

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [April 22, 2021, 11:01am UTC](https://community.thunkable.com/t/help-build-a-timer-that-works-when-the-screen-is-locked/1238064/3 "2021-04-22T11:01:45Z")

</div>

@Balanced_Kitchen @tony.ycy.program

Check this out

> [@How to create a timer that runs in the background or with the app closed completely](https://community.thunkable.com/t/how-to-create-a-timer-that-runs-in-the-background-or-with-the-app-closed-completely/515590):
>
> Hey Thunkers! I wanted to create a quick tutorial to demonstrate how to have a timer that runs in the background independent of the app being open or closed. First, here is the visual layout, of course, i doubt yours will be the same as mine exactly but for demonstration purposes, here you go! Step 1: Create 1 stored variable. This guy will do our real “timer” work and keep track of everything we need Because I utilize the variable as a list, I need …

---

<div class="post-metadata">

**Author:** ![Balanced\_Kitchen](https://avatars.discourse-cdn.com/v4/letter/b/839c29/32.png) [@Balanced\_Kitchen](https://community.thunkable.com/u/Balanced_Kitchen)\
**Post date:** [April 22, 2021, 11:31am UTC](https://community.thunkable.com/t/help-build-a-timer-that-works-when-the-screen-is-locked/1238064/4 "2021-04-22T11:31:41Z")

</div>

An interesting solution. I also thought to use the local time, but I assumed that there is an easier option 🙂

---

<div class="post-metadata">

**Author:** ![Balanced\_Kitchen](https://avatars.discourse-cdn.com/v4/letter/b/839c29/32.png) [@Balanced\_Kitchen](https://community.thunkable.com/u/Balanced_Kitchen)\
**Post date:** [April 22, 2021, 11:52am UTC](https://community.thunkable.com/t/help-build-a-timer-that-works-when-the-screen-is-locked/1238064/5 "2021-04-22T11:52:58Z")

</div>

I added synchronization with the local time and now everything is OK. However, everything turned out to be in vain because I have an event when the timer becomes 00:00:00, which cannot happen when the screen is locked. I will build the timer in html. The web viewer I think works in background mode.

---

<div class="post-metadata">

**Author:** ![Balanced\_Kitchen](https://avatars.discourse-cdn.com/v4/letter/b/839c29/32.png) [@Balanced\_Kitchen](https://community.thunkable.com/u/Balanced_Kitchen)\
**Post date:** [April 22, 2021, 1:30pm UTC](https://community.thunkable.com/t/help-build-a-timer-that-works-when-the-screen-is-locked/1238064/6 "2021-04-22T13:30:14Z")

</div>

The html file is ready. Will anyone help me integrate the features into it Post Message and Receive Message. With Post Message you need to set the time in seconds and Receive Message to trigger a play sound and this should happen when the timer is 00:00:00. I admit I have no idea how to do it.  
[timer.txt](https://community.thunkable.com/uploads/short-url/em3Ci6tZwIowOPMXPyvCEr8cXNH.txt) (4.6 KB)

[https://x.thunkable.com/copy/983001297d524c97619314788a5e711f](https://x.thunkable.com/copy/983001297d524c97619314788a5e711f)

---

<div class="post-metadata">

**Author:** ![Balanced\_Kitchen](https://avatars.discourse-cdn.com/v4/letter/b/839c29/32.png) [@Balanced\_Kitchen](https://community.thunkable.com/u/Balanced_Kitchen)\
**Post date:** [April 22, 2021, 2:25pm UTC](https://community.thunkable.com/t/help-build-a-timer-that-works-when-the-screen-is-locked/1238064/7 "2021-04-22T14:25:09Z")

</div>

It turned out that the web viewer does not work for iOS either. Obviously it is impossible to make a timer with Thunkable. I do not understand why basic sensors do not work in the background, given that good practices show the opposite. I hope someday this will change!

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [April 22, 2021, 2:43pm UTC](https://community.thunkable.com/t/help-build-a-timer-that-works-when-the-screen-is-locked/1238064/8 "2021-04-22T14:43:22Z")

</div>

The stored variable works. @darren has an example that is worth looking at.

---

<div class="post-metadata">

**Author:** ![Balanced\_Kitchen](https://avatars.discourse-cdn.com/v4/letter/b/839c29/32.png) [@Balanced\_Kitchen](https://community.thunkable.com/u/Balanced_Kitchen)\
**Post date:** [April 22, 2021, 4:06pm UTC](https://community.thunkable.com/t/help-build-a-timer-that-works-when-the-screen-is-locked/1238064/9 "2021-04-22T16:06:51Z")

</div>

If I don’t bother you, can you send link!

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [April 22, 2021, 5:19pm UTC](https://community.thunkable.com/t/help-build-a-timer-that-works-when-the-screen-is-locked/1238064/10 "2021-04-22T17:19:23Z")

</div>

Here you are

> [@New to thunkable, trying to hire someone to finish my app](https://community.thunkable.com/t/new-to-thunkable-trying-to-hire-someone-to-finish-my-app/1015826/12):
>
> Hey John! To my knowledge, this is a limitation rather than a bug. Here is a quick video explaining a work around I did for a similar app about a year ago:

---

<div class="post-metadata">

**Author:** ![Balanced\_Kitchen](https://avatars.discourse-cdn.com/v4/letter/b/839c29/32.png) [@Balanced\_Kitchen](https://community.thunkable.com/u/Balanced_Kitchen)\
**Post date:** [April 23, 2021, 5:30am UTC](https://community.thunkable.com/t/help-build-a-timer-that-works-when-the-screen-is-locked/1238064/11 "2021-04-23T05:30:02Z")

</div>

Timer synchronization is not a problem for me (when restarting the application, if the timer is still counting down). The problem is if the timer has expired while the application is in the background. Then I have an event (such as a bell ringing) that will never be triggered. I am looking for a solution to this problem. So far I have not found and therefore option two - no timer 🙂  
Thank you though!

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [April 23, 2021, 10:04am UTC](https://community.thunkable.com/t/help-build-a-timer-that-works-when-the-screen-is-locked/1238064/12 "2021-04-23T10:04:56Z")

</div>

The first thing that comes to mind for such situation is to add an event to Google calendar and let it manage the alert/notification for the user.

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [April 23, 2021, 12:30pm UTC](https://community.thunkable.com/t/help-build-a-timer-that-works-when-the-screen-is-locked/1238064/13 "2021-04-23T12:30:08Z")

</div>

If you are attempting to have an event fire with the phone closed, that can’t happen as a thunkable app has little to no real control over background events beyond watching/waiting for push notifications.

The method shared is the only way to have a count up or count down timer (for now) that works with the phone closed. The issue being they can’t fire events with the phone closed but because it’s a math operation and not a running event, you can in fact keep time this way. A traditional timer is a “running event” and all events stop running when the app enters the background.

---

<div class="post-metadata">

**Author:** ![tchind](https://avatars.discourse-cdn.com/v4/letter/t/ebca7d/32.png) [@tchind](https://community.thunkable.com/u/tchind)\
**Post date:** [May 3, 2021, 5:19am UTC](https://community.thunkable.com/t/help-build-a-timer-that-works-when-the-screen-is-locked/1238064/14 "2021-05-03T05:19:13Z")

</div>

> [@How to send reminder to specific user](https://community.thunkable.com/t/how-to-send-reminder-to-specific-user/635847/11):
>
> I hv got it!
> 
> Check this out
> 
> [How to set Reminder Notifications with Zapier in Thunkable X? - YouTube](https://community.thunkable.com/t/how-to-set-reminder-notifications-with-zapier-in-thunkable-x-youtube/1258683)

Here it is

---

<div class="post-metadata">

**Author:** ![Balanced\_Kitchen](https://avatars.discourse-cdn.com/v4/letter/b/839c29/32.png) [@Balanced\_Kitchen](https://community.thunkable.com/u/Balanced_Kitchen)\
**Post date:** [May 5, 2021, 7:00am UTC](https://community.thunkable.com/t/help-build-a-timer-that-works-when-the-screen-is-locked/1238064/15 "2021-05-05T07:00:54Z")

</div>

I will definitely try it. Thank you for the video.

---

<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, 1:25pm UTC](https://community.thunkable.com/t/help-build-a-timer-that-works-when-the-screen-is-locked/1238064/16 "2024-11-08T13:25:03Z")

</div>


