简体   繁体   English

从另一个活动返回后,FragmentActivity调用onCreate

[英]FragmentActivity calls onCreate after coming back from another Activity

So, I need some code to be executed only once when FragmentActivity is created. 因此,我需要一些代码在创建FragmentActivity时仅执行一次。 I was method thining that protected void onCreate(Bundle savedInstanceState) is only called first time when FragmentActivity comes to flow. 我的方法protected void onCreate(Bundle savedInstanceState) ,只有在FragmentActivity出现时才第一次调用protected void onCreate(Bundle savedInstanceState) But, then from that FragmentActivity I go into another and after coming back from that second one, onCreate gets called again. 但是,然后从那个FragmentActivity进入另一个,然后从第二个回来,再次调用onCreate I was looking on FragmentActivity cycle and that's not clear for me. 我一直在寻找FragmentActivity周期,但这对我来说还不清楚。 Is there method that only gets invoked at very beginning and not after coming back on that activity any more? 是否存在仅在一开始就被调用而又不在该活动之后被调用的方法?

Could you verify that FragmentActivity.onDestroy is not called? 您可以验证是否未调用FragmentActivity.onDestroy吗? If it does get called, maybe the second paragraph of the of the Activity lifecycle could help you understand what's going on. 如果确实被调用, 那么活动生命周期的第二段也许可以帮助您了解发生了什么。

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

相关问题 Activity 调用 onCreate 返回 - Activity calls onCreate on Back 回到FragmentActivity后,出现IllegalStateException - IllegalStateException after coming back to a FragmentActivity 从另一个startActivityForResult()返回之后,将数据传递到选项卡式FragmentActivity的一部分中的Fragment - Passing data to a Fragment in part of a tabbed FragmentActivity after coming back from another startActivityForResult() 从另一个活动回来后如何保持活动中的价值 - How to keep the value in the activity after coming back from another activity 将从使用startActivityWithResult触发器onCreate调用的Activity返回 - Will coming back from an Activity called with startActivityWithResult trigger onCreate 从另一个活动回来后,ArrayList变得清晰 - ArrayList gets clear after coming back from another activity 从活动回来后刷新片段 - Refresh fragments after coming back from an activity Android 对象在 onCreate 后返回 null - Android Object coming back null after onCreate 从另一个应用程序返回后,如何从“活动”中清除“片段”? - How to clear Fragment from Activity after coming back from another application? 从“相机活动”返回后,活动丢失了数据 - Activity loosing data after coming back from Camera Activity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM