Is there a fragment equivalent of the SINGLE_TOP flag?

android, android-fragments, flags

Solution

It appears that there is no equivalent.

The best option currently is to call remove(fragment) as part of your transaction, although the downside to that is that it seems to pop anything that's above it in the stack

Problem

I have an application which replaces the fragment in a container when the user navigates. (Based initially on the method android studio creates if you start a new project with spinner navigation selected) I want the user to be able to press the back button to go back through previous pages, but not have to press back a million times to exit the app. I can add the fragments to the backstack but it means there can be a huge stack OR I have to find the last instance manually and clear part of the stack. If I use activities I can just launch my intents with the SINGLE_TOP flag. Is there an equivalent method I can use when replacing fragments?

Original source