When the activity gets recreated due to config-change or memory issues when in stack (going back to the activity stack) the attached fragment gets recreated as well.
In my case, the fragment cannot be recreated because it is linked to some non-serializable data that cannot be simply reassigned (refactored) on the lifecycle methods. So the app crashes due to unitialized properties in the Fragment.
The Fragment with this issue is a DialogFragment that could simply be ignored and closed instead of be recreated and shown again. How could I remove the fragment in the case the activity gets destroyed?