ATimeTracker
ATimeTracker copied to clipboard
State loss on double screen rotation
Hi, this issue has relation with #146
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 #146 in activities:
- Activities: check disappears, fragment appears, fragment disappears, message fragment disappears, the menu disappears, and the text disappears;




- ActivityTimes: pop-up menu disappears;
- EditTime: am changes to pm, calendar changes, date change, element state loss, back to the previous screen;




- Settings: font size changes from medium to small;


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.
- https://developer.android.com/guide/components/activities/activity-lifecycle
- https://developer.android.com/topic/libraries/architecture/viewmodel
Thanks for the report.
Possible duplicate of one or more of #57 #55 #52 #51 #59 #49 #48 #47 #46 #44 #43.
I modified the title as "data loss" would sound like persisted data would be lost (i.e. in this case the saved time ranges that matters for this app) but as I understand it the data that is lost here is the message in the dialog box or currently selected values before applying them, which while irritating and certainly are bugs, are much less severe then loosing any data with business value.
We should look into the links provided with explanation about how to maintain the state variables.