I have a complex data object in my Activity. A floating dialog like fragment is shown when user wants to edit data for that object. This fragment has references to some parts of data object. User makes live edits to that data from this fragment. Some simple text editing, for example.
While user is editing this data, a configuration change happens.(the famous Orientation change). Upon change, every thing is automatically recreated by system including the floating fragment just like it was before.
I don't know why, Android should have just restarted the Activty, why save and reload something that was manually created afterward ? But that's another question.
So, while fragment's new clone is back, it has lost that "Connection" to the data object. Because that data object's gone too and we have a new one with all user edits lost. I want to save the state just before configuration change and regain it afterwards.
How can an Activity determine if it is being launched by user (should start from scratch) or is being recreated by system on a config. change ( should reload saved state) ?
And after that, how to re-establish the fragment's connection to data object so the user can continue editing like nothing ever happened ?