Zhuinden / simple-stack

[ACTIVE] Simple Stack, a backstack library / navigation framework for simpler navigation and state management (for fragments, views, or whatevers).
Apache License 2.0
1.36k stars 76 forks source link

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

Open Zhuinden opened 1 year ago

Zhuinden commented 1 year ago

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).