Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 294
Tiago Nunes Avatar asked Sep 02 '25 17:09

Tiago Nunes


1 Answers

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.

like image 136
Tiago Nunes Avatar answered Sep 05 '25 06:09

Tiago Nunes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!