android - Understanding the fragment and activity lifecycle and backwards navigation -


i'm trying understand odd behavior. have activitya calls method in oncreate() add fragmenta r.id.fragment_container. inside fragmenta have button attaches fragmentb using activitya's fragment manager (getactivity().getsupportfragmentmanager()) , replacing r.id.fragment_container , add backstack. have button starts new activityb. when navigate activityb get: activitya onresume(), fragmenta onresume(). when navigate fragmentb get: fragmentb oncreateview(), fragmentb onactivitycreated() 2 onresume().

so questions is...why view state saved when new activity launched , not when fragment replaced , reattached. looks better restore state rather recreate views , fetch data again. seems opposite behavior expect i'm missing fragment state saving/restoration step or something. seems activity pausing fragmenta (and activitya) when activityb launched , restoring on pressed when fragmentb attached fragmenta gets destroyed. i'm sure there's way prevent can't seem figure out. thoughts?

just below question 4 tags android,android-fragments,android-lifecycle& android-navigation .put cursor on while black box pop . click on info tab , best links study topics along links books .

hope you


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -