简体   繁体   English

什么时候不调用 onRestoreInstanceState?

[英]When onRestoreInstanceState is not called?

Docs describes when onRestoreInstanceState IS called: 文档描述了onRestoreInstanceState被调用:

This method is called after onStart() when the activity is being re-initialized from a previously saved state, given here in savedInstanceState.当活动从先前保存的状态重新初始化时,在onStart()之后onStart()此方法,此处在savedInstanceState 中给出。 (...) This method is called between onStart() and onPostCreate(Bundle) . (...) 这个方法在onStart()onPostCreate(Bundle)之间onStart() This method is called only when recreating an activity;此方法仅在重新创建活动时调用; the method isn't invoked if onStart() is called for any other reason .如果出于任何其他原因调用onStart()则不会调用该方法

I'm super curious what does " onStart() is called for any other reason " mean in context of onRestoreInstanceState ?我非常好奇在onRestoreInstanceState上下文中,“出于任何其他原因调用onStart()什么意思?

The normal lifecycle of an Activity looks like this: Activity的正常生命周期如下所示:

  • onCreate()在创建()
  • . .
  • onStart()开始()
  • onResume() onResume()
  • onPause()暂停()
  • onStop()停止()
  • . .
  • onDestroy()销毁()

The lifecycle callbacks between onStart() and onStop() can occur over and over again if the Activity is completely obscured by another Activity .如果Activity完全被另一个Activity遮挡,则onStart()onStop()之间的生命周期回调可能会一遍又一遍地发生。 In this case, onStop() is called when the Activity is completely obscured by another Activity .在这种情况下,当Activity被另一个Activity完全遮挡时,将调用onStop() When the Activity is made visible again, onStart() will be called without onRestoreInstanceState() being called because the Activity is not being recreated.Activity再次可见时, onStart()将被调用,onRestoreInstanceState()不会被调用,因为Activity没有被重新创建。

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

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