Search code examples
androidkotlinandroid-fragmentsandroid-architecture-navigationandroid-bundle

Does the data (Bundle) from navArgs persist after the killing and recreation of the Activity (and Fragment) by the system?


This question has been answered already by Ian Lake, from Google. I was suggested to recreate the question on StackOverflow and answer it myself, so it might help someone else who googles it :)

When using Navigation API, and SafeArgs:

val args: SomeFragmentArgs by navArgs()

Does the args field keep its values after the activity gets killed by the system and recreated? In other words: does the Bundle sent to the Fragment survive?


Solution

  • The answer given to me by Ian Lake (from Google):

    The Bundle of arguments sent to a Fragment are indeed part of the Fragment's saved instance state. There's no reason to store it again separately

    So indeed, it does survive.