Is it possible to create a counter that starts, so it works when you open the application and when you exit the application it keeps the value and when you return to the application it works and completes from the previous value and when a certain value is reached (hours for example) it deletes the value and counts from zero … This process is repeated every time The app works
Use background task extension by @Xoma
There you will find many sample aia’s also for countdown also
Use tiny db when user close the application and store the value in tiny db when user reopen the app check the value of tiny db on screen initialise
This post was flagged by the community and is temporarily hidden.
can be achieved easily using the tiny db for example, you need no extensions
is it possible?
when is the app closed?
yes it’s possible, look for the tinydb documentation.
if you want a clock ticking even when the app is closed, save the current timestamp as a value in a key then close the app then reopen it and get the stored timestamp subtract it from the current timestamp then you get the time since the last time you used the app until now.
but if you want to execute some functions when certain events happen when when your app is closed, then definitely you’re gonna need this extension
in a closed application, nothing is ticking
this is impossible without Background Tasks Extension.
you only need some logic during Screen.Initialize
store everything you need in TinyDB (the hour for example) and do some calculations in Screen.Initialize, for example has that value reached while the app was closed, if yes, start counting from zero and calculate what needs to be displayed now
no need for a background extension
PS: I moved this discussion back to your other thread, because you not really need the background extension…
store the current time, say 09:30, using a clock that stores current time every second until you close the app then close your and open it after some time, say 12:45, and retrieve the stored time which is 9:30 by triggering any event like screen initialization or button click, subtract the 2 values you get 3 hours and 15 minutes if it’s greater than your desired duration say by 45 minutes then restore the value but subtract the 45 minutes from your next duration
and how will it help if the value needs to be reset at a certain point in time when the application is closed?
reset it when the screen initializes if the resulted value of subtraction is > your desired duration
you can do this without extensions, unless you want to execute a background function that needs to be executed once the desired duration is exceeded
Do you wanna like this kind of app? @wael_khalfi
gsr_timer.apk (5.5 MB)
Without bugs… fixed all.
It works without background task extension…
Only logics. Start the counter , kill the app… then reopen after few sec or min or hr
It is completely connected with online time. So app must be connected in two cases
- While clicking the button
- While screen open… other than no needed
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.