Open ch8n opened 3 years ago
As a simple rule of thumb, if your application logic permits, commit your fragment transaction in onCreate or in response to user interaction. If your fragment is added based on an async event such as a network call, things get trickier.
The reason behind this is that the fragment’s host activity has already saved its UI state and might get destroyed anytime now. The fragment transaction that you are about to do now, will not be saved in the bundle and when the user returns to this activity, this transaction will not be restored.
Article
medium: https://proandroiddev.com/illegalstateexception-you-used-a-fragment-99816e7cf71b
Topic Covered