Android Developer
easyandroid-activity-fragment-lifecycle
Explain the Activity and Fragment lifecycle and common Android pitfalls.
Answer
Lifecycle events control when UI is created, resumed, paused, and destroyed.
Pitfalls:
- Doing heavy work on the main thread
- Leaking contexts in singletons
- Not handling configuration changes
Best practice: move state into ViewModel, use lifecycle-aware components, and cancel work on stop/destroy to prevent leaks and crashes.
Related Topics
AndroidLifecycleArchitecture