Getting deprecation warnings for androidx.fragment.app.Fragment
:
warning: [deprecation]
getFragmentManager()
inFragment
has been deprecated.
What to do?
Yes, using the support library Fragment along with the getSupportFragmentManager is the right thing to do.
we will use getChildFragmentManager() Return a private FragmentManager for placing and managing Fragments inside of this Fragment. we will use getParentFragmentManager() Return the FragmentManager for interacting with fragments associated with this fragment's activity.
Short answer: I call and use getChildFragmentManager() in my Fragment's onViewCreated() method. For example: @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.
The sources of version 1.2.0
explain it in more detail:
This has been removed in favor of
getParentFragmentManager()
, which throws anIllegalStateException
if theFragmentManager
isnull
. Check ifisAdded()
returnsfalse
to determine if theFragmentManager
isnull
.
In Kotlin:
fragmentManager
, requireFragmentManager()
are deprecated.
Current way: parentFragmentManager
In JAVA:
getFragmentManager()
, requireFragmentManager()
are deprecated.
Current way: getParentFragmentManager()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With