Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to do Proper Ancestral Navigation for Android App with Several Activities?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 533
    Answer it

     

    How to implement proper ancestral navigation for application with several activities one of which can swap content fragments?

     

    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). 

     

    If it still isn't really clear, it looks smth like this.

     

    MainActivity(MainFragment) -> MainActivity(SecondFragment) -> DetailsActivity -> MainActivity(MainFragment)

     

    And I want it to look like this.

     

    MainActivity(MainFragment) -> MainActivity(SecondFragment) -> DetailsActivity -> MainActivity(SecondFragment)

 0 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: