Answer the question
In order to leave comments, you need to log in
Why does fragmentmanager get destroyed after config change?
There is a fragment that is attached to Activuty as follows.
override fun onAttach(context: Context) {
super.onAttach(context)
try{
activityContract = context as IActivity
}catch (e:ClassCastException){
throw ClassCastException(context.toString() + "Активити должна реализовывать интерфейс IActivityView")
}
}
illegalstateexception: fragmentmanager has been destroyed
lateinit var fragmentManager:FragmentManager
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_search)
fragmentManager = supportFragmentManager
}
Answer the question
In order to leave comments, you need to log in
The problem arose due to the fact that I did not unbind the fragment from the Activity when changing the screen configuration.
In the fragment's onDestroy() method, you need to nullify the reference to the Activity.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question