How does fm.findFragmentById( return the correct fragment? If CrimeListActivity calls this first it will receive CrimeListFragment. At first it will be detected as null but assigened an instance of CrimeListFragment with if(fragment == null){ fragment=createFragment(); fm.beginTransaction().add(, fragment).commit(); }
But Let’s say CrimeActivity calls fm.findFragmentById( next. I know the fm is a different instance but how does it get CrimeFragment from the same
Is is that I can think of and R.layout.whatever as blueprints and setContentView as building the blueprint onto my activity, thus I in turn could say I also have two instances of


Each FragmentActivity has its own FragmentManager so different activities can both have a fragment with ID without conflict. I wouldn’t say is a blueprint – it’s just a number. activity_fragment.xml is certainly a blueprint, but if you create more than one of those in the same FragmentActivity there will be a conflict. It’s called SingleFragmentActivity for a reason.


Thanks for the clarification!