I have one main activity with drawer layout and with content represented by fragments. I have kind of main fragment, which is initialized in onCreate() method and added to content holder. In this part navigation is pretty clear - I just swap out fragments when I click nav items.
From one of the fragments, in which I have a list of items, I can go to child activity which represents the item details. I decided to implement it as child activity, because navigation in this part isn't represented by NavDrawer, but just by Up button.
The question is - how can I properly navigate from this child activity back to main activity with proper fragment in place? The problem is that when I go back the main activity is created from scratch, so I get wrong fragment in place (the main one). And I want the one from which I went to details activity.
If it still isn't really clear, it looks something like this.
MainActivity(MainFragment) -> MainActivity(SecondFragment) -> DetailsActivity -> MainActivity(MainFragment)
And I want it to look like this.
MainActivity(MainFragment) -> MainActivity(SecondFragment) -> DetailsActivity -> MainActivity(SecondFragment)