I have a progress bar (swirly waiting style) defined in xml as:
Using android:configChanges
is bad practice, because it might get you in much worse trouble.
Also saving a variable at onSaveInstanceState
didn't work for me, since you won't get updates while the Activity is destroyed.
I ended up using a ResultReceiver inside a Fragment that doesn't get destroyed by using setRetainInstance(true)
.
A good article concerning this problem can be found here: https://www.androiddesignpatterns.com/2013/04/retaining-objects-across-config-changes.html
Also see my answer here: https://stackoverflow.com/a/54334864/6747171