ANDROID APP using MIT APPINVENTOR

Creating a Confirmation Notification on Exit from App

Isn't it a good practice to ask the user before he finally exits from the application? Suppose you are playing a game and by mistake you have touched the back button, what should be the expected behavior of the application? Should it quit silently or should it confirm to you before finally exiting from the current application?

Obviously you will agree to this, as an expected behavior you app should ask the user Do you really want to exit, so that if he has pressed the back button by mistake can resume the play.


Component to Use

Notifier is the component that fits our need. We can use notifier to pop-up any kind of notification or alert to the user within the app. As you have already completed the chapters on Easy Call App and Auto SMS reply App, there we did enabled the user to save the data into the database. But have we used any kind of notification or alert for the user to know whether the data has been successfully stored or not? Well if we have skipped that during those lessons, we will cover it here.

You can find the notifier in the palette under the User Interface heading.

Creating Notification when User Exits Application

It is a non-visible component that means you will not see it on screen and it will be placed under non-visible components heading on to the viewer.

Creating Notification when User Exits Application

In our scenario we want to trigger the notifier when user presses the back button.

Creating Notification when User Exits Application

Event for monitoring back button press is within the screen page as you can see from the blocks editor. It will display a dialog box to choose which will be saying Do you really want to Exit? with buttons as Yes and Cancel.

Creating Notification when User Exits Application

When this dialog is open to select the choice, based on the user choice it will trigger another action which will decide whether to continue or to exit from the application.

Creating Notification when User Exits Application

It means that when the user have selected the Yes button then only it will close the application and if user selects Cancel, then the application won't be closed.