Source code is available here: https://github.com/novemberox/NavigationTest It\'s modified version of this sample: http://developer.android.com/training/implementing-navigat
After reading @cyfur01's answer, I came up with very simple solution that fixes the behavior.
Override this method in your Activity (or ideally in some BaseActivity to have it fixed for all subclasses) and it should work as expected:
@Override
public boolean navigateUpTo(Intent upIntent) {
boolean result = super.navigateUpTo(upIntent);
if (!result) {
TaskStackBuilder.create(this)
.addNextIntentWithParentStack(upIntent)
.startActivities();
}
return result;
}
It leaves all work to Android implementation and then just checks return value of navigateUpTo(upIntent) which is false when an instance of the indicated activity could not be found and this activity was simply finished normally. Which is exactly the case when we want to create and start the parent Activities manually. Also note we don't have to call finish() here as it was called by the super method.