s, this works only in very specific situations. Specifically, what breaks horribly is replacing a fragment, putting it in the back stack and then rotating the screen while the new fragment is shown. From what I understood, the old fragment does not receive a call to

onSaveInstanceState()

when being replaced but stays somehow linked to the

Activity

and this method is called later when its

View

does not exist anymore, so looking for any of my

TextView

s results into a

NullPointerException

.

Also, I found that keeping the reference to my

TextViews

is not a good idea with

Fragment

s, even if it was OK with

Activity

's. In that case,

onSaveInstanceState()

actually saves the state but the problem reappears if I rotate the screen twice when the fragment is hidden, as its

onCreateView()

does not get called in the new instance.

I thought of saving the state in

onDestroyView()

into some

Bundle

-type class member element (it's actually more data, not just one

TextView

) and saving that in

onSaveInstanceState()

but there are other drawbacks. Primarily, if the fragment is currently shown, the order of calling the two functions is reversed, so I'd need to account for two different situations. There must be a cleaner and correct solution!