Alarm Continuing After Stop Alarm Button is Pressed Coding Help

Hello, I have been working with MIT App Inventor for the past week now. My plan was to make an app that would remind the user that their class is starting soon (5 min before) . I have gotten all of the storage coding correct and I am currently stuck on this bug that I can not seem to fix.

When the user creates a class, its input is stored in the TinyDB and when a certain criteria matches, it will ring out the alarm and set a variable to "true". For example, If you create a class and day of the class is on Friday and the class starts at 9:30 AM the alarm will ring out at 9:25 AM. If left to ring, the alarm will ring out until the minute is over. In our example the Alarm will start at 9:25 and will keep ringing until 9:26. I have a stop alarm button when pushed, the alarm will stop playing and will set another variable to "true". Since the alarm will always play until the minute is over, I added these two variables so when both are true, the alarm will not be played.

The bug is when the user leaves the classes page, (where the alarm function and the stop alarm page is) and goes to another page or has the app minimized. The alarm will play just fine, but when the user goes into the classes page to stop the alarm, the button does not do anything and the alarm will keep on ringing. It will not stop until the minute is over.

I have tried everything that I could think of but nothing would work. If anyone has a solution to my problem you can look in my code and see what is wrong and how can I fix it. Alternatively, if you have a different way the alarm logic should work, please let me know. Thanks!

Do you need to stop the clock timer as well as the player ?

Personally, I want to only stop the player while keeping the clock timer going because if the user has multiple classes that they need to be reminded the first class would ring out but the later classes would not.

However If there is no fix for that I have no problem also stopping the clock timer as well as the player. If I do need to go down that route, would I have to use the "set clock 1 Timer enabled" and set it to false?

Now that I am thinking about it some more, I think it would work with stopping the time. If you still have a fix or a solution to where it only stops the Player and keeps the Clock timer going then please let me know. Thanks!

Or change the content of the tinydb value being tested....

I don't want to change the content of the tinyDB as it's being used weekly. A class would need to ring on the same day and the same time the following week.

OK, change the content of that tinydb tag, then use another timer to "change it back" after the minute has passed. I am guessing that in the timer, even though you ask the alarm to stop, the timer test is still within the minute window, so sets the alarm off again. Or just stop the first clock for a minute, then restart it.

How would you have the clock stop for a minute? I don't see any wait blocks or something to stop if for a minute.


Try this. It works ....