Why can't I close my app?

This can happen if you open a Screen more than once.
See here: App Inventor Tutorials and Examples: Manager Screen | Pura Vida Apps

For example:

5 Likes

Thank you for your example.
Your picture was very simple, so it is easy for a beginner like me to understand.

2 Likes

Yes, as you say this example works with a few screen application, but I have an application with more than 100 screens. How can I close them all when closing the application?

Well done for ignoring the warning sign at 10 screens !! Surprised and amazed you got to 100 screens.
You should really only have 1 (perhaps 2 if you include Screen1) screen open at any time in your app, so you should only have to close 1/2 screens when you close your app. If you have more screens open than that then you are not switching screens correctly.

3 Likes

Seriously, more than 100 screens? That won't work either way.
And as Tim said, if you have open more than two screens at the same time you will run into memory issues (crash).

2 Likes

I have 23 screens but when I finish the app, it will have more than 100 screens. When I want to change the screen I use: “Open another screen. Screen name: …” but I don’t close the others screens and, for the moment, I don’t have any problem with the memory, the only problem is I can’t close the app with: “Close application”

1 Like

When you do not close screens properly, you run into issues. Why are you not listening to advice Daniel?

Continually close doing this from Screens creates instances of your Screen1 in system memory. Sooner or later your app will crash as you open additional Screens, then improperly leave them for Screen1.

Anke provided you this link App Inventor Tutorials and Examples: Manager Screen | Pura Vida Apps Here is another acceptable way to change and manage screens Tribblehunter's Multiple Screen Method

Regarding " the only problem is I can’t close the app with: “Close application”, if you use Companion for live development, as stated in Taifun's tutorial:

Current limitations of the AI Companion app:

  1. The close screen block triggers the Initialize event instead of the OtherScreenClosed event.
  2. The close screen with value block triggers both the Initialize and OtherScreenClosed events instead of only the OtherScreenClosed event.
  3. The close application block does not work, a message 'Closing forms is not currently supported during development' will be displayed instead.

close application only works after you compile the app (create the apk and load on a device).

2 Likes

If I close the screen, I go to the Screen2, if I open another screen to Screen1, I go to Screen1 and I want to go to the Screen1. How can I close that screen and go to the Screen1?

1 Like

ejecutar ... cerrar pantalla ... Screen1

should work .... close screen ... Screen1 closes the Screen you are on at the moment and returns to Screen1.

2 Likes

Can you show me with a picture, please?

1 Like

it does not look like you followed the already provided links...
why?

see also tip 1 here

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

2 Likes

@danielpaz3270

Oh, I already did that Daniel.... close The example with the red X is what you are doing now.

The example with the green check mark is what you should do to return to Screen1 and free up memory resources.

2 Likes

It’s actually very very simple.

Go to Blocks

On the main Screen1 screen:
1a) Add the instruction: “When” Screen1-Back Button “execute” close the application "(which is in the Screen blocks)
1b) Create the Procedure: “Close_screen”, whose only instruction will be to execute “close screen” (which is in the Control blocks)
1c) TO ALL BUTTONS that lead to another screen, add: Call Procedure “Close_screen”

ON ALL OTHER SCREENS other than Screen1:
2a) Create the Procedure: “Close_screen + (screen name)”
2b) Add the double instruction: “When” (screen name) -Back button “execute: a-- Call Procedure” Close_screen + (screen name) " // b-- Open another screen + (name of the screen) screen)"

1 Like

yesss. if you make a apk and you run it on device. it closed application.

1 Like

I think this is a little bug in the MIT App Inventor.
The best that is working for me is Closing the Screen first with an If statement and later closing the App.

See image:

MIT_App_Inventor_Close

If you have more than 1 screen you can add them unther thatScreen 1 with the same syntax.
Example:
"close screen with value result Screen2"
"close screen with value result Screen3"
and so with all the available screens.

I hope this helps

to avoid these complicated rules, why not just using the recommended manager screen solution?
this also brings other advantages, see again here The recommended method of switching screens in App Inventor

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

1 Like

The problem is Closing the Apps., is not with managing the screens. MIT app inventor is failing in 2 of my apps with only 1 Screen.
And the recommended solution will be far more complicated.

to close the app, use the close application block and it works from any screen but only if you follow the manager screen method...

Taifun

1 Like

Post a (simple) test aia with 3 screens.

And see also here: