We Are Going To Discuss About Since the Android getFragmentManager() API is deprecated, is there any alternative?. So lets Start this Java Article.
Since the Android getFragmentManager() API is deprecated, is there any alternative?
- Since the Android getFragmentManager() API is deprecated, is there any alternative?
If I understood you well
getFragmentManager()
is now deprecated
we will usegetChildFragmentManager()
Return a private FragmentManager for placing and managing Fragments inside of this Fragment.
we will usegetParentFragmentManager()
Return the FragmentManager for interacting with fragments associated with this fragment's activity. - Since the Android getFragmentManager() API is deprecated, is there any alternative?
If I understood you well
getFragmentManager()
is now deprecated
we will usegetChildFragmentManager()
Return a private FragmentManager for placing and managing Fragments inside of this Fragment.
we will usegetParentFragmentManager()
Return the FragmentManager for interacting with fragments associated with this fragment's activity.
Solution 1
This method was deprecated in API level 28.
Use FragmentActivity.getSupportFragmentManager()
Original Author faskN Of This Content
Solution 2
If I understood you well getFragmentManager()
is now deprecated
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.
so, if you deal with fragments inside a fragment you will use the first one and if you deal with fragments inside an activity you will use the second one.
you can find them here package androidx.fragment.app;
Original Author Mina Samir Of This Content
Solution 3
If you using AndroidX Fragment androidx.fragment.app.Fragment
you can use
getActivity().getSupportFragmentManager()
Original Author teteArg Of This Content
Solution 4
I used parentFragmentManager
instead of fragmentManager
.
(If you are using androidx Fragment
.)
https://developer.android.com/jetpack/androidx/releases/fragment#1.2.0
getFragmentManager() deprecation: The
getFragmentManager()
and
requireFragmentManager()
methods onFragment
have been deprecated and
replaced with a singlegetParentFragmentManager()
method, which
returns the non-nullFragmentManager
theFragment
is added to (you can
useisAdded()
to determine if it is safe to call).
Original Author Yoju Of This Content
Conclusion
So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.