How to destroy previous Ragment?

Asked

Viewed 433 times

2

In my Android project I navigate between fragments, in one of these fragments, there is a list that receives information from a json. It appeared the need to update this list every 1 minute, I’m using postDelayed(this, 60000); which calls a thread, which uses changeActivity(ActivitiesListFragment.class, null);to update the list.

It’s working, the list is updated in a new fragment.

The problem is that when I press the back button, it goes back to the previous list as it was not "destroyed".

How do I start a new fragment and exclude the fragment previous?

  • You could use the Fragments backstack here you have an answer, then I put an answer here http://stackoverflow.com/a/18306258/3861347

  • 1

    When adding Fragment, use replace, not add. This way you will always have only one Fragment.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.