Search code examples
androidhtmlcordovaphonegap-pluginshybrid

How to set the BACK button on the black bar menu on the bottom of android screen to turn my app off?


I made a hybrid app (game) which contains many html files. And when I play and click on this button enter image description here my app turns to previous page. Now should I set this button to turn my app off (and if yes how?) or maybe you have a better idea?


Solution

  • Take a look at https://cordova.apache.org/docs/en/latest/cordova/events/events.html#backbutton, documentation for tapping Back button and triggering the event.

    May I suggest you just disable the back button action - do not close the app, do not close back. To go back or turn off the app, you should have an action on your screen, and the confirmation prompt.