clock working while switching screens.

65 views
Skip to first unread message

תומר אהרונהיים

unread,
Mar 18, 2017, 5:37:52 AM3/18/17
to MIT App Inventor Forum
.(hello everyone.i am working on a app where i have in screen 1 different information for the user to add and when he finishes he is sent to screen 2 where he has a timer counting backwards(every person has a different timer.
there is an option to add another person information but the problem is that when i go back to screen 1 and come back to screen 2 the timer of each person i already added is restarted. I wanted to know if there is a way to make the timer of each person keep counting down even when i pass between different screens
Ty in advance for the helpers!

Taifun

unread,
Mar 18, 2017, 10:27:13 AM3/18/17
to MIT App Inventor Forum
before leaving the screen store the current countdown time and store it in TinyDB
then later when coming back, use the stored time to continue counting down
TinyDB tutorial by Stephen

Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 

tomer

unread,
Mar 20, 2017, 12:57:03 PM3/20/17
to MIT App Inventor Forum
i do not need the clock to continue counting from the point i left the screen and come back, but to continue its count even when i am looking in a different screen

Taifun

unread,
Mar 20, 2017, 1:07:07 PM3/20/17
to MIT App Inventor Forum
how many minutes does the countdown run?
just calculate the end time of the countdown and store that time in TinyDB 
after coming back, calculate remaining minutes = calculated end time - current time

it probably would be easier to use only one screen...

Use different screens wisely
Before starting to create another screen, first you should think about is it really necessary? See also Building apps with many screens and SteveJG's post about advantages/disadvantagesbecause in only one screen you also can use vertical arrangements to simulate different screens, just set the arrangements to visible = true/false as needed... See also Martyn_HK's example about how to use Tabs in App Inventor and another example from Cyd
      
Taifun

Abraham Getzler

unread,
Mar 21, 2017, 12:55:31 PM3/21/17
to MIT App Inventor Forum
You have to change the problem to one of record keeping.
There is no need to use the Clock as an alarm clock, just use it
to periodically check an ENROUTE table stored under TinyDB
tag ENROUTE:

Columns:
  timeDue (ms from 1970)
  deliveryMan (name, yes it's sexist)
  deliveryAddress
  deliveryDetails (more info on what is being delivered, etc.)

When a new delivery request comes in, compute the timeDue deadline before adding
it to the table.  Optionally sort the table in ascending order by timeDue to bring the
urgent ones near index 1, to help  spot imminent lateness.

When a delivery is complete, copy its row to a COMPLETED table, with maybe a timeDelivered column added, 
then remove its row from the ENROUTE table.

Other tables to consider:  PENDING (new orders not yet sent out for delivery),
AVAILABLE (deliverymen not out on deliveries, depending on your business).

Suggested TinyDB hygiene - treat these tables like a container of milk on a hot day.
Keep them in the refrigerator (TinyDB) when not in use, 
take them out just when you need them, and immediately replace them
in the refrigerator (TinyDB) after you use (update) them.

See the TinyDB and Lists sections of my FAQ

ABG


Reply all
Reply to author
Forward
0 new messages