Android Back Button Problem

  

In Android, when the back button clicked, app will navigate to previous page that should be closed.

Take tutorial "Build a Mobile App in 5 min" as an example,

I go through:
1. Login Page (sign in) > 2. Home Screen (click an item) > 3. Todo Page (save data) > 4. Home Screen > 5. click Android back button > 6. previous Todo Page > 7. click Android back button > 8. Home Screen > 9. click Android back button > 10. Login page (without clicking logout button).

While, 6. should exit the app instead of going to previous Todo page or login page.

So how to prevent this?  

Hi Simon,

That's interesting question. Let's wait for someone to answer this.

Thanks and Regards,

Suraj Borade

Solution

Native apps generated by OutSystems are based on Cordova, which has a default behavior of forwarding the back event to the underlying WebView, making it act as a browser's back button.

You can probably implement your desired behavior by adding an event listener for the back button and issuing some commands to cordova. I found this stack overflow topic which doesn't have a marked solution, but may eventually help you: https://stackoverflow.com/questions/28766683/close-cordova-app-on-back-button 

Solution

Hi Simon,

You might want to check one of these:

- Exit On Back forge component: http://www.outsystems.com/forge/component/1805/exit-on-back

- Backbutton plugin for Cordova: https://www.npmjs.com/package/cordova-plugin-backbutton


João Pedro Abreu wrote:

Native apps generated by OutSystems are based on Cordova, which has a default behavior of forwarding the back event to the underlying WebView, making it act as a browser's back button.

You can probably implement your desired behavior by adding an event listener for the back button and issuing some commands to cordova. I found this stack overflow topic which doesn't have a marked solution, but may eventually help you: https://stackoverflow.com/questions/28766683/close-cordova-app-on-back-button 

Thank you!


Hello Simon Tsui,

It is a default functionality of mob application, its only store previous page information and is default behaviour.

Same problem I face when I am working on the mobile applications because outsystem use cordovo plugin. You need to modify the cordovo plugin by adding custom code in addEventListerner.

Jorge Martins wrote:

Hi Simon,

You might want to check one of these:

- Exit On Back forge component: http://www.outsystems.com/forge/component/1805/exit-on-back

- Backbutton plugin for Cordova: https://www.npmjs.com/package/cordova-plugin-backbutton


Yes I recommend this component to control how the app should behave.


Note: That's why Apple don't like to have back button.