findFragmentByTag() returns null after perform a FragmentTransaction using replace() method
I've fixed it! I called getSupportFragmentManager().executePendingTransactions()
after doing the transaction and it worked! After calling that method I can get the fragment using both findFragmentById()
and findFragmentByTag()
methods.
if you use setRetainInstance(true)
than you can't use findFragmentByTag()
in onCreate
from the Activity. Do it at onResume
see the documentation: setRetainInstance