Timer not working


Hello, I have this timer, which when it reaches 90 without having any input on the user's screen, it goes back to screen1, the problem is that it is not working, before it worked, when it reached about 1.5 min without input the screen changed to screen1. Can anyone help?

This is the clock setting.
imagem
Did I do something wrong?

Not seeing any issues with this test

1 Like

Try/test by moving the SET timer enable true to the click event (after the set global Counter).

  • I have the impression that when I trigger the "click event", the code does not return to the " Horario initialize" event, since the screen has already initialized.

Therefore, it never starts the clock.

1 Like

Set the timer interval to 1 sec. You have it to 90 secs, but later you are using a counter to reach 90.

2 Likes

First of all, you do not switch screens correctly...
See App Inventor Tutorials and Examples: Manager Screen | Pura Vida Apps about how to do it correctly

Your timer interval is 90000, i e. 90 seconds and you are counting to 90, so after 135 minutes, which is 2 hours and 15 minutes you like to close the current screen and go back to Screen1, is my understanding correct?

Is your app up and running all that time or do you expect this to work also when the app is in the background?

Taifun

2 Likes

Hello, thanks for the example but I already discovered the error.

It's weird because I had the time interval for 1 sec and it didn't work and from there I changed it to 90 sec. Thank you very much, it worked!

So how do you suggest I do it? I've already seen the link that sent it, for reference I have screen1 > screen2 > screen3 how do I do it so that when the timer expires screen3 go directly to screen1. And yes my app is to stay running all that time.

It was only necessary to change the time interval, but thanks for the help!

1 Like

Use the close screen block
Taifun

2 Likes

As I said, the layout I have is the following
screen1 > screen2 > screen3,
if I use the close screen block the screen will change to screen2, my goal is that it changes directly to screen1.

Even if it works, Taifun is right

  • It's not advisable to switch windows without closing the others; Memory and Security as main factors, then we could talk about other inconveniences
1 Like

Rsad the tutorial
Use the manager screem method

and you will understand, that screen1 is the manager and closing another screen will bring you back to the manager screen
Taifun

2 Likes

Understood, thank you very much!

1 Like

I will study this subject further, thank you very much!

1 Like
2 Likes

Thank you!


Is this right?


This way it is shorter and works the same way i need.

If Screen1 is actually closed, yes. Otherwise "Open another screen" will open another instance of Screen1, so there will be two Screen1s in the App's allocated memory. Also, if leaving a Screen, it is best to stop any Clock Timers that are on it.

A procedure cannot be named "procedure".

Have you considered using Virtual Screens? They a much better solution for multi-screen Apps.

When we define virtual screens, we use one 'real' App Inventor Screen (most often Screen1). Screen-sized Vertical Arrangements on it are displayed/hidden as required - they are the Virtual Screens. This is generally a better approach for multi-screen Apps, they share data without having to "pass" it between screens and it also reduces code duplication, making the App more efficient and the code easier to follow if you have to return to it at a later date.

So, instead of separate "houses", virtual screens are "rooms" of the same "house".

2 Likes