• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps About the addToBackStack() method

ac4android

Well-Known Member
Nov 3, 2015
198
29
In very simple terms, lets say I have several fragments and on the UI, the user can click on any item which then selects one of the fragments. The user must be able to use the "back" key to get back to previous screen.

I tend to end up with these few lines of codes:
Code:
FragmentTransaction ftx = getFragmentManager().beginTransaction();
ftx.replace(R.id.my_container_frame, fragment);
ftx.addToBackStack(null);

QUESTION: But doesn't the null in addToBackStack(null) mean it won't be added to the backstack?
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones