I have implemented onRestoreInstanceState and onSaveInstanceState. They both work successfully when the app is minimized (by pressing the home button, or another activity is in the foreground). However, when I minimize the app and the kill the process (by opening the list of current processes and ending that one) the app does not restore the saved instance state. How can I make it restore that saved state? Is my best option to write the savedInstanceState bundle to a file using serializable (thus having something stored that on the hard drive, rather then RAM), then reload the savedInstanceState from the file?
How can I make it restore that saved state?
You can't. That's not what the saved instance state is for.
Is my best option to write the savedInstanceState bundle to a file using serializable (thus having something stored that on the hard drive, rather then RAM), then reload the savedInstanceState from the file?
Your "best option" is persistence, such as a file, database, or SharedPreferences
. Your specific approach seems odd.
Saved instance state is only for temporary information, such as the contents of a form that the user has filled in but not yet submitted. Anything beyond that does not belong in saved instance state, but rather in some sort of persistent data model. This is no different than building a Web app, where the data that you have in your DOM and JavaScript variables are not going to live forever, but instead need to be store somewhere (typically on a Web server).