The stopwatch to continue counting even when the screen is closed?

I put a stopwatch on a screen and I want to make the time run even if that screen closes and another screen opens if someone presses the back button.
And if possible and when the application closes.
The time count will continue until it is decided to stop the time part.
Can such a thing be done?
Please some help on how it can be done

this do not need background technology.

You just need to save the start time stamp in TinyDB.
Then retrieve this data and compare to the time now, you will know how many minute/seconds passed.


This here in the picture, is something I come across for the first time, how do I get it? Where do I find it?


right click on it, external input.

In clock1 I added what you show me, but button1 what do I map it to to add what you show?
Because it doesn't count anymore, it just flickers

Sorry I don't understand what you want to do.
And what formatTime does?

I want when if the timer starts it continues to count even t the back button has been pressed and the screen closes and another screen opens. Keep counting until the user comes back and presses stop

As @Kevinkun has already indicated, you cannot switch screens and leave a clock running. It is best to stop the clock when switching screens, capture the value and store to a tinydb. Then when you return to the stopwatch screen, capture the current time, and add this to the value stored in tinddb before starting the clock again.

What you want to do should work if you are using virtual screens because you are on the same real screen, the only issue might be that your stopwatch clock may conflict with other activities you are running.

Thanks for the replies.
I thought maybe it's possible, if the backbutton is accidentally pressed, it keeps counting the time.

Does not matter.
I will put a notice if e.g. someone wants keeps counting the time while doing something else, to close the screen with the middle round button

It's on its own real screen, not in a virtual.

The start time is stored in TinyDB, so you can change screen or close app. Next time you back to this screen, the stopwatch will continue, like not stopped.

1 Like


Should I leave this like this to work properly?
As a separate app it worked fine

these blocks will work no matter how you open /close the screen.

I asked this because this app alone works properly as you describe it.
But elsewhere with more than one real screen it doesn't work for me, if I press the back button it closes the time counting

With this here that I have outside from qlock1 together it doesn't count, but it flickers

but in your blocks, you are using your code, not mine.

and did you set the timer.TimerEnabled to true when screen is opened?

it flickers

Sorry for not understanding quickly
Now with the resume it continues from where it left off but the reset to reset the time doesn't work

I press the reset button, it turns off the time only on the screen, I press the start, it appears after the resume button and when I press it, it continues to count continuously,
how would it happen with the stop and then with the reset that everything that has been counted delete

When the reset button is pressed in any screen, you need to record that in TinyDB. Maybe with a tag named ResetButtonPressed and set it to TRUE.
When the timer screen opens, BEFORE continuing the timer, check if ResetButtonPressed is TRUE. If it is, then don't continue the timer and set it to 0. Don't forget to set ResetButtonPressed to FALSE.

how many buttons you have? what's the function of each? are they on same screen?


Now I can close the application, change the screen and it continues to count and in order to see it, I have to push the start button again so that it can still be seen that it is counting.
If it was possible to make it appear to continue counting without pressing the start button...
Thank you Kevinkun.

Sorry, I am not sure I understand what you want to do.

you have 2 buttons, one for start the stopwatch, one for stop it?