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

Data loss on double screen rotation #161

Open
davirec opened this issue Mar 19, 2022 · 0 comments
Open

Data loss on double screen rotation #161

davirec opened this issue Mar 19, 2022 · 0 comments

Comments

@davirec
Copy link

davirec commented Mar 19, 2022

Hi, this issue has relation with #160

A data loss problem occurs when data is accidentally deleted or state variables are accidentally assigned with default or initial values. This issue is related to the activity's lifecycle (1). When a screen rotation occurs, the activity is destroyed and resumed. Data loss will happen if the developer does not save the variables before the destruction and restore them after creation. To avoid this, the developers have to implement both the logic necessary to save the activity state in the onSaveInstanceState() callback method and the logic to resume its state in the onRestoreInstanceState() callback method.
Another way to avoid data loss problems is to use the view model, designed to store and manage UI-related data in a lifecycle-conscious way (2).

We found failures similar to issue #160 in activities:

  • AttachmentActivity: text disappears from the fragment
  • CollectionActivity: menu list disappears
  • CollectionMembershipActivity: menu list disappears
  • CreatorActivity: list menu disappears, popup menu disappears, text and popup menu disappears
  • ItemActivity: message fragment disappears, menu list disappears, search disappears, and the text disappears
  • ItemDataActivity: message fragment disappears, menu list disappears, the text disappears, fragment title changes, fragment title changes, and text is lost
  • MainActivity: menu list disappears
  • SettingsActivity: view properties changed

Note:

  • Double screen rotation: It is executed twice to reach a state that should be exactly the same as the screen before if no data loss occurred.
  • A data loss problem occurs when data is accidentally deleted or state variables are accidentally assigned with default or initial values.
  1. https://developer.android.com/guide/components/activities/activity-lifecycle
  2. 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