Explain the mobile application lifecycle and how you handle state preservation when an app is backgrounded.