Problem with Timer App

I want the timer to run as long as App is not exit other wise it should be stopped when the App is not in use like when i click some exit button in my App it should get disabled again.

Yes indeed - the extension should deliver on that. The best way to know is to try it.

Another method that might work is to have a seperate Clock Timer constantly move or change something on screen, so the Phone knows the App is active. For example, displaying a tiny image and replacing it with another tiny image every 5 seconds or so, or perhaps re-sizing a label width that is used as a horizontal spacer.

if i failed to do the later then do suggest me how to import your free extension to App inventor then!
thanyou and bye for now....

Check this APK:

So try it out and report.

You could always approach this from a different angle, and work out when you are now from when you were then....use Taifun's Tools ActivityStateChanged event to grab the time and counter position when the app is paused, and to add the "gap" back to the counter on resume....

timerSleep.aia (24.9 KB)


Here's the extension-free solution, just comparing present time to a TinyDB saved millisecond ...
After Restart

Counting Start timer_abg.aia (3.2 KB)


Oops, I let my sample run longer, and I learned that my math was wrong in breaking up the Duration to hh:mm:ss.
I was thinking in decimal fractions, getting seconds > 60.

To get proper conversion, get a countdown timer from the Gallery, like

1 Like

I am working with this issue and i got resolution I had set my clock always fires to diable mode thats why the issue!

A post was merged into an existing topic: Problem with finding Block

my problem is solved my app is simple and need not extension as i had set my timer always fires to disable mode!

No, unfortunately that won't solve the problem, not even if TimerAlwaysFire is enabled.
On many devices, the Timer is stopped in idle mode (Doze) / background. So I recommend the approach from @ABG as the simplest solution (if you don't need to pause the Timer).

I finally got around to fixing my time math, and consolidated it all into a single value procedure (hh_mm_ss). Here is the new code:
After Restart Capture Counting

Start timer_abg.aia (5.4 KB)

(I got the idea to consolidate the time math into a single value procedure, after replacing an old ceiling fan with a new fan boasting of a greatly reduced parts count to ease installation.)


Hello Abraham,

this is really a very simple and also ingenious idea (approach) to solving the general problem with the inaccuracy of the Clock component and the problem in idle mode (sleep mode, timeout / Doze).
Great as always, thank you Abraham! :+1:

Greetings from Germany,

Btw, I had the same idea when creating my CountDownUp extension:

Thanks for the peep into Java, I'll save it for if and when I need to dive into extensions.

BTW, I suspect my hh_mm_ss procedure could be replaced with a Clock FormatTime call with the right pattern. I did not have time to shorten it.

@ABG So what is your solution if the timer (count up) is paused (even several times)?

That would probably require an extra saved variable, like accumulated runtime, like the Memory button on a calculator. That looks like a different problem statement to me.

Yes but how? Maybe like this:

I seem to have lost a post just now.
here is my revised version with pause, no extensions, less commentary (until I can find the lost post.)

Paused Reset Running timer_abg_paused.aia (6.9 KB)

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.