Timer scomparso automaticamente ─ countdown (not) working in background

Yes we know, but elapsed time is handled when the counter is restarted / app resumed.

As @Taifun said, it all depends on what @Nicola_Imperati wants. I am simply showing a method using native blocks (no extensions). One could always keep the screen alive with another clock and a notifier.

Yes, we've known all this for years, and that's precisely the basic requirement for a countdown app, namely that the timer remains active. What would be the point of a countdown app if you couldn't notice the end of the countdown?

I doubt that, unless the device is being charged during the test. Samsung devices, in particular, are always very restrictive when it comes to energy saving. I own several Samsung devices myself.

Also consider that the timer is not "that accurate" for this kind of usage.
On the companion I measured that every 2 minutes it is off by 1 second ( compared to the internal systemtime ), it means 30 seconds every hour

But what would I have gained by telling a lie? :relieved:

I didn't claim that, only that the timer wouldn't stop while the device is charging. However, I doubt that a one-hour countdown would be successful if the app isn't brought to the foreground several times in between. I have two dozen test devices here, and it doesn't work on any of them with Android ≥ 6.

1 Like

Here's an example using my countdown extension (above) and a timer (below). After just 5 minutes, there's a discrepancy of 8 seconds.

Blocks

Of course, the timer can be corrected, at least to some extent, by synchronizing it with the system time. However, this is a bit tricky. So why not use my extension? It doesn't lose a single millisecond, no matter how long the countdown runs.

Wait a minute, but that was actually exactly what I did, in fact I called her back every now and then. :upside_down_face:

Sorry, but I don't understand what you're trying to tell me.

1 Like

In the end, you were absolutely right. As long as the count was called every now and then, it would recover... but when I didn't call it for an hour, it remained frozen... so as you say... it's mandatory to activate a foreground service... period!

1 Like

This is all you need. The countdown doesn’t lose a single millisecond and works also in the background / idle mode regardless of the duration.

TermosifoniTimer3.aia (920.3 KB)

Build the APK and try. (Note: PreventDoze only works with the APK.)

Unfortunately I can't open the AIA file

TermosifoniTimer3.aia (911.2 KB)

1 Like

Can you tell me how your extensions work?

You have my aia and the blocks. So where is the problem?

They work, or…?

Sure it works, but I was just curious...anyway it's fine anyway

I don't think showing you the source code would help you.

But I was asking in general terms; I would never have dared to ask you for their code.

Ok, and what do you want to know?