El temporizador se reinicia cada vez que cambio a la pantalla de inicio.

117 views
Skip to first unread message

Víctor Barrantes Andrada

unread,
Mar 24, 2018, 12:59:29 PM3/24/18
to MIT App Inventor Forum
Estoy haciendo una aplicación con varias pantallas. En la pantalla de inicio he puesto un temporizador para ir contando la duración de la actividad. Cuando estoy en esa pantalla funciona perfectamente, pero cuando cambio a cualquier otra pantalla y después vuelvo a la de inicio, el contador de tiempo vuelve a empezar de cero. ¿Qué debo poner en el resto de pantallas para que siga funcionando? ¿Cómo lo debería hacer? Estoy dando mis primeros pasos y no encuentro solución en los vídeos que he consultado en You Tube. ¿Alguien me puede ayudar? Gracias.

TimAI2

unread,
Mar 24, 2018, 1:59:02 PM3/24/18
to MIT App Inventor Forum
When you switch screens the timer will stop working.

Two options

1. Staying with multiple screens, capture the time of start of the activity to a variable, then before switching screens capture the time again. Save these values to a tinydb. When you return to the same screen again, start the capture time process again and add to the previous values.

2. Get rid of all the multiple screens a just use vertical or horizontal arrangements as virtual screens and change their visibility as you switch virtual screens.

Read all this:

Use different screens wisely

If you decided to use different screens, then you should switch them correctly, else you will run out of memory after a while...      
The recommended method of switching screens in App Inventor
(Thanks Taifun)

Also see demo: multiscreen.aia

Reply all
Reply to author
Forward
0 new messages