App with several Screens

Hi veryone,

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):

image

I’m using the Open Another Screen method:

image

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?

Thanks in advance,
Jose

See below topic and maybe use tinydb to store values

General Tips and Tricks for App Inventor/Kodular

3 Likes

Hi dora_paz,

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?

Thanks again,
Jose

Maybe if you save the screen names in a list and use random block might work but you have to close screens correctly

image

Randomly you mean that every time you click a button in screen1 you will go to diffident screen?

So in that case it’s better to use arrangements as screens and toggle the visibility.

1 Like

Used random integers generator block 1 to total screen.

And join screen and global generator screen number

And open another screen
And used block
if ture
Than closed screen
And open another screen

Is that what you want?
randomscreen.aia (2.9 KB)

1 Like

Hi evereyone,

Thanks for your comments.

Maybe I didn’t explain well the situation.

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).

He you have the apk and aia to check it:

severalScreens.apk (4.8 MB) severalScreens.aia (24.1 KB)

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).

Again, thanks for your help,
Jose

This is how kodular and the other MIT App Inventor distros work.
You have two options:

  1. 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.
  2. Just use different arrangements as screens.
1 Like

About this proposal:

With this option you have to close also the current screen when you go to another to avoid memory issues.

Please, how can I close the current screen and go to other one?

And about

Just use different arrangements as screens.

Please, do you know where can I get more information about this?

Thanks in advance

You can google it there are videos in Youtube also
Example: YouTube

2 Likes

image

3 Likes

Try this: severalScreens2.aia (24.9 KB)

almost the same as @Italo has suggested.

5 Likes

Hi everyone!

First, thanks to all of you. It’s very important sharing information to improve knowledge.

Finally, the next code works perfectly. As I wanted!:

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:

image

And you make a new screen using the copy screen button, in the new screen, automatically the value is updated:

image

And it happen in every text that contains the screen name!:

image

It’s very useful but, take care!

Again, thanks for helping & sharing!

Jose

2 Likes

I use these procedures to switch between screens and it works well for me:

01

Then in the button you want to change screen you add the procedures as follows:

02

That’s something I didn’t know! Anyways, I never use more than one screen, but is good to know.

1 Like

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