App keeps crashing when switching screens via button

Hello all!
I'm developing a simple app which displays information based on the category you choose.
To achieve that, I used TinyDB to store data of which button was pressed, which would then show a different result on another screen.

Currently I'm just working on the bare-bones framework of the system, so I can add more details later, but at a point, it was refusing to let me set the background color of the screens to white. Any other color was fine, but setting it to white (through any method) lead to the color being switched back to "Default" immediately. So, I used "When screen is initialized, set screen background color to..." to set the color to white.

But after I did that, it started constantly crashing whenever I pressed a button to switch screens. At first it would crash when I rapidly switched between screens, but now it crashes when I first start the app and press a button to switch from screen 2 to 3. (The entire app turns off)

It's been a while since I coded anything, and this is my first project in a while. Am I making a glaring mistake that I'm just not aware of?

I've included the file below, please tell me if anything else is needed!

Thank you.

buttontest.aia (42.2 KB)

  1. You neglected to mention that you were using clock timers. Clocks need to be stopped before switching screens. This is probably the cause of your crashes
  2. You should learn how to switch screens correctly, your current approach leaves screens open, which will build the stack and eventually cause an Out Of Memory message

Thank you very much! I suspected it might've involved the clocks.
I put in "When clock Timer -> Set Clock timer enabled to False" - that should fix it.

As for your second point, do you have any resources you can point to, in order to help me figure out how to turn off the screen when switching to another?

Thank you again :slight_smile:

also

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
 
1 Like

Thank you, this should work well :smiley:

Yes, but only if the screen is not closed with / after screen switching.
However, if the screen is closed, the clock / timer is automatically disabled.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.