Handling the Mobile Device Back Button

In Android applications, it is very common for users to use the physical back button on the device itself, instead of a back button on the screen.

Apache Cordova uses an event listener called "backbutton" to catch when a user presses the Android back button. The prepackaged Apache Cordova Android project in Profound UI already handles this event and looks for the app to handle it in the Rich Display File simply by including a button with the id of "btnBack".  The button can be hidden on the screen if desired.

The button can have a JavaScript onclick action or a bound response property.  For example, if you bind the response property to a named RPG indicator that is also called btnBack, the RPG code to handle the back button would look as follows:

If btnBack = *On; // handle back button response using RPG here EndIf;

If a button with the id of "btnBack" is not defined on your screen, the application simply exits when the user presses the back button on the device.

Note that you can change the default "backbutton" event listener, if required, by modifying the app.js file in your project.