Clear way for exciting Up Navigation
One of the most common types of Android apps is content driven apps (every future action in the application depends on the content shown on a specific screen). Usually such apps have number of different screens to represent multiform content. And here comes the problem with up navigation.
Imagine that you have for example such screens:
- Content Details screen.
- Content Collection screen
- Landing screen of the app.
And what if every screen in the list can lead user to the Content details screen?
Let’s illustrate this with screen flow diagram:
Many ways to navigate to one screen makes really problematic to design user friendly up navigation.
Google has rather simple description on how to implement “Up Navigation” correctly (Up Navigation).
As far as you see this implementation does not fit our needs (remember that we need to have multiple parent activities for Content Details Screen).
Wait a second, maybe other guys have already created a solution for this. Lets see analyze up navigation in most popular apps:
- Medium Android App:
Up button simply copies behavior of the back button.
Almost same as Medium app. Except the case with push notifications: after you opened received notification and press up button you are navigated to Facebook main screen.
Didn’t find and up navigation. Maybe I was looking bad.
Same as Facebook.
In one word: the behavior is pretty strange. I created a card (card #1) in the board that links to another card (card #2). When I opened card #2 within card #1 and pressed up button Trello navigated me to the board screen. Looks good, but when you press back button you are brought back to card #2. Seems that when user presses up button Trello just open board screen on top of the card screens.
The right way
More advanced example:
Remember that up navigation logic should not influence back navigation (or replace it). Back button should navigate use back in the stack of screens but not modify it on the fly.
Great, we found how it should look like from user point of view.
I’ve came to conclusion that the best way to implement such up navigation is to pass the parent activity link (for example class of the activity) to the child activity.
then when you handle up button click you can check whether you have this referrer. And if yes then just open referrer activity, but if not then recreate back stack manually:
The nice thing when you recreate back stack manually that you can modify that stack depending on the current content displayed on the screen.
The only drawback of this approach is that you need to pass parent activity to each child activity.