I need to create an app with several screens. From every screen has to be possible to move to another screen (it has no a predefined hierarchy):
I’m using the Open Another Screen method:
The problem is that every time I move from one to other screen it seems that a new one screen instance is created with new information (the initialze method is raised every time)
It means that I’m losing session information in every scree, I need to close a lot of screens, the memory can be out, etc.
I’m sure I’m doing somehing wrong.
Please, anyone has any idea how can I control the Screen instances in order to not creat multiple screens?
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/disadvantages , because in only one screen you also can use vertical arrangements to simulate different screens, just set the arrangements to visible = true/false as needed…
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
App Inventor works best if you use images whose size matches the size you want them to appear on your screen. If you import larger images into your app, your app may run out of system memory. Using Images with App Inventor
[/quote]
Thanks for your reply. I had already read that information previously. But, as far I understand, this information is to manage hierarchy ordered screens.
What I need to do is to move randomly from one screen to other. It means, I would like to know how to manage screen ids or something similar in order to prevent to create multiple instances. If I have the control of every screen id I could create every screen only one time. I beleive the method I’m using is not the proper one.
Do you think It’s possible to do it with the tools we have in Kodular?
When I say “random” I want to say that the user can choice any screen to move to. I mean, the user can go from screen1 to screen4, from screen4 to screen2, screen2 to screen4, screen4 to screen3, screen3 to screen1, an so on. The user decides what screen want to get.
The problem is I’m using the methond “Open another screen name…”. Every time I use this method, the screen where move from is maintenied opened and I’m opnening a new one (with same name).
This is a very simple app. It has 4 pictures and you can click in every picture to open and create (not to move) to a new screen.
If you execute the app and type something in the text box, you can see the effect. the effect is that you aren’t move fromo one screen to other, the effect is that you are creating multiple screens with the same name (and occuping memory).
This is how kodular and the other MIT App Inventor distros work.
You have two options:
You have multiple screens and before you go to other screen store all your data to tinydb and when the screen initialize again get the data from the tinydb. With this option you have to close also the current screen when you go to another to avoid memory issues.
Additionaly to the code, I want to share with you an idea and a discovery:
Idea: Use a local procedure (I named it myTinyData in the previous code) to store in a TinyData component information neccesary to maintain in every screen adding as a prefix the ScreenName . In my case, I want to maintain the typed in the txt component. With this procedure I can assure the values for every screen are the proper ones.
My discovery: The vars that contains the screen name (i.e: “Screen1”) are updated with the new screen name when the screen is copied to other one. I.e., If you have text var like:
And you make a new screen using the copy screen button, in the new screen, automatically the value is updated:
And it happen in every text that contains the screen name!: