Hello all,
I am trying to make an simple app that is counting the time I am spending on the app and each time the app is running but I am doing something else (so my app is suppose to be on background) the app is suppose to tell me that I spend time outside the app.
To do this :
-
setup a timer with a count up of 1 sec and loop.
-
each time the timer fires I am incrementing a variable (count) by one. (so far so good )
-
the first time I am launching the timer I am keeping the seconds since 1970 in a variable. (init)
-
each time the timer fires I am doing the difference between init and my current seconds since 1970. So I am supposed to have the real time between the two events. If this difference is the same as my “count” variable (more or less) I consider that I was not using my and it was in background.
this is suppose to work because our apps do not “work” in background so the timer does not fire when the app is not running (running on background)
my issue is that the apps never behave the save way. Sometimes the count stops (which is good) but sometimes it is not.
Does anyone can help me on this ?
I extract a part of the app.
https://x.thunkable.com/copy/d1e49c11e82e96ed0858040aa78db2ba