I\'m referring to Why use Fragment#setRetainInstance(boolean)?
The reason I ask so is for Activity
to handle rotation, Official Activity Documentation encou
Because you are misunderstanding its use. setRetainInstance(true)
should only be used in fragments that are like solo elements/modules. Fragment that handle sockets etc. an don't have a GUI really benefit from being retained. Fragments with a GUI should probably not use setRetainInstance(true)
. Also any fragments that goes to the backstack shouldn't use setRetainIstance(true)
.
You could generalize it to any fragment which handles only data/connection etc. should use setRetainInstance(true)
. But there is a multitude of different ways to use Fragments, which wouldn't benefit of setRetainInstance(true)
.