I saw many examples for how to get the Context in BaseFragment like this:
protected lateinit var ctx: Context
override fun onAttach(context: Context?) {
super.onAttach(context)
ctx = context!!
}
And then we can use the context instance in our other fragments that extend BaseFragment. One, two, three (it's offered to get Context from onViewCreated()) and so on. It looks like workaround.
I also had some cases when "fragment detached from Activity" exceptions occurred while using getActivity() or getContext() in Fragment.
So, what's the true way?