simple-stack icon indicating copy to clipboard operation
simple-stack copied to clipboard

Backstack is not available in a child Fragment's onCreate after process death

Open Zhuinden opened this issue 2 years ago • 0 comments

Currently, the general usage is to use onViewCreated, however the only reason why it's unavailable in onCreate is that internally, the Backstack is maintained by a platform retained fragment.

Although on second thought, as Fragment.onCreate is executed by Activity's super.onCreate after process death, it wouldn't have a state changer, so calling lookupService on it then would have also failed anyway.

Still, this means that Fragment.onCreate is kind of a liability. Not sure what can be done about this other than saying "use onViewCreated instead" or do a handler.post. Most likely just documentation issue, as this is fragment design (I don't think we need to recreate services until the state changer is set).

Zhuinden avatar Apr 25 '23 17:04 Zhuinden