When starting a specific action of my application, the user is "welcomed" with a dialog box that must fill in with some data in order to continue. Then, in the activity itself, the user has two buttons that allow him to dynamically create and delete an infinite number of fields (which consist of several views).
As you know, when the screen orientation changes, activity is restarted, so all information is lost. Obviously, this can be problematic.
To handle screen orientation, the Android documentation advises developers to use onRetainNonConfigurationInstance () . The only problem is that if you use it to save objects in context, all views associated with it will leak. This is even more problematic in my case, since the data in this activity are inherently related to his presentation, which, in turn, is related to its context.
The Android documentation does not recommend developers to handle configuration changes themselves. They state (and quote) "in general, a short-term solution that will only complicate their lives later"
I can easily get around the initial dialog by creating, for example, hasBeenShown Boolean and setting it to true. I can even get around the problem of “dynamically created views” by storing my metadata: in this case, the number of fields generated, their type, their relative position to each other, their text or selection, etc ... (with some minor errors, but nothing serious).
But since fields (views) are generated dynamically using layoutInflate (and therefore we can have an infinite number of views), when you re-generate the same fields after changing the screen orientation, the application becomes really very slow even on the emulator. With 20 fields (approximately 120 views) on a real device (Samsung Galaxy S), it took almost 1 minute to complete.
, (, , ), , Samsumg Galaxy S 10 .
, , ?
(1) - reset? ( , , - , = P)
(2) - , android ?
(3) -
(4) - , , Doom Android docs , .
P.S: offtopic, , ?