Stopping the Rotation Crash: Managing UI State with ViewModel and LiveData
Learn how to use ViewModel and LiveData to prevent data loss and crashes during Android configuration changes like screen rotations.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Learn how to use ViewModel and LiveData to prevent data loss and crashes during Android configuration changes like screen rotations.
Activities get destroyed on rotation and take your UI state with them. Here's how ViewModel + LiveData fixes that, with a working counter example and three ways to verify the lifecycle behavior yourself.