Jelly Bean is here, so I thought it appropriate to examine some of the new features.
If you are lucky enough to be working with apps targeted on Honeycomb or above, you have probably noticed that the back button has been supplemented by a new button called ‘Up’. What you may not have figured out, unless you’ve explicitly coded for it, is exactly what this button is supposed to do.
According to the API documentation, the back button navigates through the application in reverse chronological order whilst the Up button navigates backward through the hierarchy of your application. Of course if you have navigated hierarchically through an application the two actions will be the same.
So when does this button help? Imagine working with something like an email client. You start from the list of mails in your inbox. When you click on an email, an activity is launched to display that email and on the view for that activity are next and previous buttons. Using the next button, you work your way through the list of emails. To get back to the inbox using the back button, you would have to visit each email again. The home button on the other hand would take you to the parent activity: the inbox.
In reality, far from every application supports the Up button. Perhaps, the biggest single reason for the being that prior to Jellybean it was hard work to make it happen! Jelly Bean makes the implementation of Up navigation vastly simpler than it used to be.
Instead of having to register callbacks for the Up button in the Action Bar and create then send Intents to launch the right Activity at the right time, all the developer has to do is to add an annotation android:parentActivityName to each activity which specifies their parent. Android then takes care of building a back stack and ensuring the users get a nice consistent experience. In our email example, the developer would simply specify that inbox was the parent of the mail viewer and the Up button would return the user to the inbox regardless of how many emails they had viewed. It seems a simple change but used correctly will make applications much easier to navigate.