Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The message isn't persisted when the app is paused #223

Open
davirec opened this issue May 9, 2023 · 0 comments
Open

The message isn't persisted when the app is paused #223

davirec opened this issue May 9, 2023 · 0 comments

Comments

@davirec
Copy link

davirec commented May 9, 2023

In the double screen rotation test to detect data loss, an application failure was identified: message loss.

Before and after double screen rotation

The occurrence of data loss is a common problem that arises when important data is unintentionally deleted or when state variables are mistakenly assigned with default or initial values. This issue is closely related to the lifecycle of the activity (1). During a screen rotation, for example, the activity is destroyed and resumed, and if the developer fails to save the variables before destruction and restore them after creation, data loss is likely to occur. To prevent such data loss, developers must implement the logic necessary to save the activity state in the onSaveInstanceState() callback method and restore its state in the onRestoreInstanceState() callback method.

Another effective approach to avoiding data loss problems is to utilize the view model, which is specifically designed to store and manage UI-related data in a lifecycle-conscious manner (2). By employing this technique, developers can minimize the risk of data loss and ensure the smooth functioning of their applications.

References:

https://developer.android.com/guide/components/activities/activity-lifecycle
https://developer.android.com/topic/libraries/architecture/viewmodel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant