kaaholst / android-squeezer

Remote control for your Logitech Media Server ("Squeezeserver" etc) and players.
Apache License 2.0
75 stars 15 forks source link

Data loss while using the app (input text disappears on-screen rotation) #759

Closed davirec closed 1 year ago

davirec commented 2 years ago

When I perform these sequences of events, the input text disappears on-screen rotation:

  1. Go to the Main activity
  2. Tap in Name or IP address of server
  3. Write 192.168.1.1
  4. A screen similar to this will appear:

Before rotation:

  1. Force the pause from the activity and then return to the activity (double rotation). Note that the input text disappears. Note: the pause from activity can be performed in several ways. We suggest using a double rotation (starts in portrait, goes to landscape, and back to portrait) with this function previously enabled in the smartphone.

The expected behavior is the return to the previous state with the input text of the previous image.

However, the input text disappears.

After rotation:

Device:

Data loss 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).

  1. https://developer.android.com/guide/components/activities/activity-lifecycle
  2. https://developer.android.com/topic/libraries/architecture/viewmodel
kaaholst commented 1 year ago

I’m closing this issue because it has been inactive for a few months.

Thank you!