Search code examples
androidbackconvention

Android back-button-overriding etiquette / guidelines


I have an app in which the user logs in from a main activity, and then can browse through a heirarchy of entities using listviews. So, the Activity stack would look something like this:

A -> B -> B -> B -> ...

where the number of B's is proportional to how deep you are in the tree of entities. Frequently, I find myself pressing backbackbackbackback to get to the root (the first 'B'), but one too many presses and I log myself out, or even leave the app. I'm considering overriding the back button so that, when pressed from the root B, it will pop up a dialog essentially saying "Log out? (Y/N)", thus blocking a string of back-presses from completely exiting the app.

I've noticed a sort of sensitivity regarding overriding the back button, though, and - while it makes sense to me - I want to know if this is considered a good use of the back button.

So: Would this be considered an appropriate/conventional override of the back button? Is there a better/more conventional way to accomplish this without overriding?

Also, so this question might be more generally useful in the future, are there any guidelines for what is acceptable/unacceptable when overriding the back button?


Solution

  • I would find this use acceptable; I've seen a number of apps that ask for a confirm before exit - if the user wants to exit an app, they usually will press the Home button and let Android handle the finish() if and when it's needed.

    I know I've accidentally exited an app by pressing back too many times :(

    Dotmister's comment about Handcent is spot on - the back button should feel natural to the user; your use seems to adhere to this, in that a user will cycle back through activities as expected for the most part. As he said though, give it a try and test it.

    Coincidentally, I have a similar flow in my app, but I've included a button for the root activity.