5

As I observed it seems that the fragment backstack is not retained after process death. So if I kill my app by putting it to background and call am kill <app> it does not recreate the fragment backstack if i take the app to foreground again.

This seems to be the case with both - using Jetpack Navigation Components and using supportfragmantmanager with addToBackStack

After Orientation change everything works as expected. So I don't know whether the backstack is always cleared after process death and cannot be retained or if there have to be some extra steps done to retain the backstack.

tscheppe
  • 588
  • 5
  • 18
  • `am kill` and "process death" (i.e., due to memory, etc.) are very, very different things. What makes you think they are related? – ianhanniballake Apr 25 '21 at 22:39
  • 1
    @ianhanniballake Saved instance state survives `am kill`, whereas it does not survive other common "kill" things that a developer might try (swiping the task off the overview screen, red "stop" buttons in Studio). If there is a better way for a developer to simulate the OOM killer terminating the app's process, I'd love to hear about it! I assume that the Jetpack implementation of fragment stores the backstack details in saved instance state. – CommonsWare Apr 25 '21 at 23:17
  • @CommonsWare as i found out now the __Logcat__ window offers a __Terminate Application__ button that works and keeps the backstack. But it is interesting to see that it only works if I do the following: App to background -> Terminate Application -> App to foreground -> App to background -> Terminate Application -> bring back go foreground. So i have todo the cycle twice to save and restore the backstack. – tscheppe Apr 26 '21 at 11:03
  • Please provide an explicit code sample that demonstrates the problem. – Brian Yencho Apr 26 '21 at 17:37
  • not any solutions for this? – Reza Jul 27 '21 at 14:35

0 Answers0