Switching screens wont initialize the screen?

Dear community,
I have read the posts regarding how to switch between the screens and I found it is best to use this code:

and not this one:

But when going back from the "settings" screen where the user enters his/her name, the name label that I have in the screen1 is not "updated".
I load the name from TinyDB when the screen1 is initialized. But it looks like the screen1 is not "initialized" when switching the screens.
If I use this code I dont have the problem:

Any help please?

Sirous

It works to me

Screen1:


Screen2:
image

Edit: chronology is meaningful here, close screen with value result woun't work if you start from the Settings screen very first time, so the condition is you must need to be in the settings screen from some other screen, lets say Screen1.

Thanks for reply.

Starting screen is not setting, it is screen1.

When we go back to screen1, name is in the TinyDB, but the label lbl_name is not refreshed.

Ok, but doesn't it work if you switch from Screen1 to Settings as mentioned above and phone back button is pressed. It won't show the label1.text as Test User123. It works to me, as Screen1 is last visited screen.

Please also share the relevant blocks from screen1.

If you're returning to another screen, you should use the first screen's when OtherScreenClosed event. The Initialize event is only run when a screen is first opened. If you open a second screen, that screen is pushed on the activity stack (view stack on iOS) and its initialize event is run. When it closes, the first screen is brought to the front and the OtherScreenColsed event is run. You'll be handed the name of the screen and the result passed if using the close screen with value block.

2 Likes

you are using the manager screen method, which is the recommended method...
for this method you should be aware ofsome limitaitons of the companion app, which have been listed here

Taifun

Thank you. works now.

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