popBackStackImmediate() will execute popping commands immediately in the call. The results of which can be checked immediately after the call. It is somewhat slower, since all popping actions are performed within the call.
popBackStack() will execute popping commands in the next cycle of the event loop (i.e. the next stage of drawing). Thus, it is asynchronous with the rest of the code. This means that FragmentTransaction will not be removed from the stack after execution. In most cases, you do not need to call FragmentTransaction right away, so it waits until everything else is complete before it happens. All this happens so quickly that the user does not recognize it.
The flag at the end is irrelevant. Currently, it can only be set to POP_BACK_STACK_INCLUSIVE . FragmentManager allows you to set the identifier in the stack. If you set the flag, it will pull out a FragmentTransaction that will match the identifier specified until one that does not match the identifier is reached, or the bottom is reached. If the flag is not set, then all FragmentTransaction that do not match the identifier are exported until one that matches the identifier or the lower boundary is reached.
source share