简体   繁体   English

来自 navArgs 的数据(Bundle)是否在系统杀死和重新创建 Activity(和 Fragment)后仍然存在?

[英]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. Google 的 Ian Lake 已经回答了这个问题。 I was suggested to recreate the question on StackOverflow and answer it myself, so it might help someone else who googles it:)有人建议我在 StackOverflow 上重新创建问题并自己回答,所以它可能会帮助其他搜索它的人:)

When using Navigation API, and SafeArgs:使用导航 API 和 SafeArgs 时:

val args: SomeFragmentArgs by navArgs()

Does the args field keep its values after the activity gets killed by the system and recreated?活动被系统杀死并重新创建后, args字段是否保持其值? In other words: does the Bundle sent to the Fragment survive?换句话说:发送到 Fragment 的 Bundle 是否存在?

The answer given to me by Ian Lake (from Google): Ian Lake(来自 Google)给我的答案:

The Bundle of arguments sent to a Fragment are indeed part of the Fragment's saved instance state.发送到 Fragment 的 arguments Bundle 确实是 Fragment 已保存实例 state 的一部分。 There's no reason to store it again separately没有理由再次单独存储它

So indeed, it does survive.所以确实,它确实存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM