Dynamically set parent activity

android

Solution

There are two concepts in play here 'Up' and 'Back'. 'Back' is the obvious one: take me to where I was just before I came here. Usually you don't need to be concerned with 'Back', as the system will handle it just fine. 'Up' is not so obvious - it's analogous to Zoom Out - from an element to the collection, from a detail to the wider picture.

Which of these fits your use case?

As per comment below: the up button pulls the destination from the android manifest, but it can be customized programmatically.

Problem

So at the moment I have an activity that can be reached from two different activities, the problem is that I can only set one activity as the parent activity in the manifest XML file. Obviously this is bad UX/UI design because the activity may send the user back to the wrong activity they were at previously and so I'm trying to dynamically set which activity is the parent activity. The trouble is I'm not quite sure how to go about this, whether in code or XML so any pointers are appreciated. :)

Original source

Related problems