• Post Reply Bookmark Topic Watch Topic
  • New Topic

Android : Handle Navigation History For Fragments  RSS feed

 
Tarun Trehan
Ranch Hand
Posts: 51
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing an android application where when user clicks on a item on navigation drawer, a new fragment is initiated to handle the use case respective to the click.

There are several entry or trigger points for one fragment. Eg : List of posts is shown under various options; Recent Post List , Top Post List , Category Post List.
From these fragments, when user clicks on a post; the selected post is opened.

Now, I need to handle "back" button click here. As of now, clicking back exits the application.
If I add calls during fragments; it does not function in the desired manner and traversal history is not maintained.

I can post code snippets if required but for now i wanted to know where i am wrong and what is the solution i can try.
Looking forward to core concept associated here.

Added Code Snippet :
 
Tarun Trehan
Ranch Hand
Posts: 51
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Implementing the method of activity solved the problem.
I tracked the navigation in a global stack and then handled the stack and invoked specific fragments/activities depending on the navigation history.
Custom history and back tracking for fragments is th best option especially when there are multiple entry points for one fragment.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!