[英]Android won't call onResume()
I have the following problem: 我有以下问题:
Activity1
and Activity2
. Activity1
和Activity2
。 Activity2
from Activity1
. Activity2
,从Activity1
。 Activity1.onPause()
is called. Activity1.onPause()
被调用。 Activity2
finishes and closes and Activity1
restarts. Activity2
完成并关闭, Activity1
重新启动。 When this happens, nothing is called for Activity1
- neither onResume()
, nor onCreate()
, nor onStart()
. Activity1
不会被调用onResume()
, onCreate()
或onStart()
不会。 What should I do? 我该怎么办? I really need
onResume()
. 我真的需要
onResume()
。
First of all: You tried to work with onCreate()
on restart - this won't work. 首先:您尝试在重新启动时使用
onCreate()
-这行不通。 See important details on the Activity lifecycle to get used to its functions. 请参阅“ 活动”生命周期的重要细节以适应其功能。
Next, since onResume()
and onStart()
should work fine according to the Activity lifecycle, make sure your code is valid and contains no bugs. 接下来,由于
onResume()
和onStart()
在Activity的生命周期内应该可以正常工作,因此请确保您的代码有效并且没有错误。
However, you could try to call onRestart()
, too. 但是,您也可以尝试调用
onRestart()
。 This is the best place to insert code which should only be executed if the Activity
restarts. 这是插入代码的最佳位置,该代码仅在
Activity
重新启动时才应执行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.