In an app I am developing, I have a custom view in which I need to save the instance state when either the screen configuration changes or the app is moved to the background. I implement onSaveInstanceState()
and onRestoreInstanceState(Parcelable savedInstanceState)
and in the case of screen configuration changes, the instance state is saved and restored perfectly. However, when the app is moved to the background, onSaveInstanceState()
is not called. This means I have no saved instance state when the activity is brought to the foreground again. My question is then:
Why is onSaveInstanceState()
not called when the app is moved to the background, and is it possible to make my view call onSaveInstanceState()
when the app is moved to the background?