I have an activity and I have a fragment stack in it and sometimes, this stack get's lost... Although I save and restore it...
I know following:
onSaveInstanceState
is not called:a) if the user navigates back, which makes sense...
b) if the activity is finished
onSaveInstanceState
is called:a) on screen rotation
I discovered through debugging, that I can't be sure, if onSaveInstanceState
is called, if screen turns black...
My app is an app, that you use for logging, meaning, you put your phone aside and come back every now and then and fill out your log... So sometimes, my activity is recreated with an empty bundle and onSaveInstanceState
was not called, although my app was in the foreground and only the screen turned off...
Questions
1) what can I do to solve that problem? Do I really have to save my fragment states and the stack persistantly?
2) on screen rotation, I can be SURE that onSaveInstanceState
is called, can I? Are there any other circumstances, where I can rely on onSaveInstanceState
?