Android phones have a separate back button that will undo the previous action. Currently only navigation is handled (automatically I believe), but if that previous action was to open a modal then I think that modal should close on back. I would also extend the same functionality to action sheets, side menus and list options too. If they are open then close them when back is pressed.
Or should Ionic leave handling of the Android back button to the developer? (Personally I think the framework should handle it)
No I agree, the framework should do the handling of Android’s back button. I’m actively working on a branch that will handle all of this for you. To be continued…
would be possible to disable somehow that back button? For example, after login, I would like to disable going back to login, or maybe detect and do automatic logout or something like that…
There is a $ionicViewService.clearHistory() that I created for another reason, but maybe this would do the trick your case? Would you be able test and see if it works for you in your case?
I also like to disable the back button on some pages. I tried using the $ionicViewService.clearHistory(), but now that there is no history, hitting the android back button closes the app. Diggin into the code I see that $ionicPlatform has some events to attach and detach events to the android back button, but i can’t make them work. Any other ideas?
You can prevent this by either clearing the navigation when the user enters the main screen. Or either add a listener on the main screen and exit the app when the backbutton is pressed.