Refresh fragment is not working any more?

I've found myself facing the same issue, and found no answer online. Finally I've found out that some optimizations were added to Fragment Transactions in Revision 25.1.1 of the Support Library. (see https://developer.android.com/topic/libraries/support-library/revisions.html#25-1-1). Disabling those for your transaction will make it work as expected:

FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.setAllowOptimization(false);
transaction.detach(fragment).attach(fragment).commitAllowingStateLoss();

Update

setAllowOptimization is deprecated. Use setReorderingAllowed instead.


Faced a similar issue after updating androidx.navigation from 2.3.1 to 2.3.2.

parentFragmentManager.beginTransaction().detach(this).attach(this).commit()

has stopped reload the view of a fragment. Everything that I found here did not help, but I noticed that separately the detach and attach operations are being performed successfully, I decided to spread their execution to different FragmentTransaction entities:

parentFragmentManager.beginTransaction().detach(this).commit ()
parentFragmentManager.beginTransaction().attach(this).commit ()

and it worked. Hope this saves someone some time.