So within my application is a form for creating a new user, with relevant details and information about the user. There's no problems there, it's just what happens when the user leaves the activity without pressing the confirm button.
Here's what I want to do:
Here's how I'm currently trying to do it:
onDestroy()
and isFinishing()
functions to find when the activity is being killed, to cover point 1 above (to then try and save all data).onSaveInstanceState
into a bundle (to cover point 2 above)onSaveInstanceState
survive the activity being killed for more resources, so when its recreated the previous state can be retrieved (as in point 3 above)?Any help would be massively appreciated.
Cheers!
I'm short on time so can't give a full detailed answer, but in brief, here are my suggestions.
onDestroy()
, use onPause()
. That's guaranteed to get called; according to the official documentation on Lifecycles, only onPause() is guaranteed. onStop and onDestroy are not.