简体   繁体   English

在finish()之后不会调用onCreate吗?

[英]onCreate not getting called after finish()?

I have an activity A and an activity B. When I go from activity A to activity B, I use the following code: 我有一个活动A和一个活动B。当我从活动A转到活动B时,我使用以下代码:

Intent i = new Intent(A.this, B.class)
startActivity(i)

Now, when I want to return from activity B to activity A using finish() , the necessary method calls in my onCreate() method don't get called. 现在,当我想使用finish()从活动B返回活动A时,不会调用onCreate()方法中必要的方法调用。 Instead, my activity looks exactly how it is as when I left it...How do I get onCreate() to get called after using the finish() method? 相反,我的活动看起来就像onCreate()离开时的样子一样。...在使用finish()方法后如何调用onCreate()

I have tested, and even the onResume() method doesn't get called after the finish() method in activity B. 我已经测试过,甚至在活动B中的finish()方法之后也没有调用onResume()方法。

What is the problem? 问题是什么?

OnCreate method will only be called when the activity is first created or re-created. 仅在首次创建或重新创建活动时才调用OnCreate方法。 Try to write a log in onResume or maybe post your code so we can inspect. 尝试在onResume上写一个日志,或者发布您的代码,以便我们进行检查。 Android provides full documentation of an Activity life cycle on their official website. Android在其官方网站上提供了活动生命周期的完整文档。 You can look here Activity Life Cycle 您可以在这里查看活动生命周期

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

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