[英]Launch App1 from App2,then press home button to the home screen,and open App1 again by press icon,why onCreate get called?
I launched App1 from App2, and here are the methods in App2: 我从App2启动了App1,这是App2中的方法:
Intent resolveIntent = getPackageManager()
.getLaunchIntentForPackage("com.example.weijunhao.launchmode");
startActivity(resolveIntent);
Then I press the home button to go to the home screen and I open App2 by pressing the launch icon. 然后,我按下主屏幕按钮转到主屏幕,并通过按下启动图标打开App2。
Why does the onCreate
method get called and not the onRestart
method? 为什么调用onCreate
方法而不调用onRestart
方法?
When an Activity
is no longer visible (like when you press the home button) it goes to the stopped state. 当“ Activity
不再可见时(如按下主屏幕按钮),它将进入停止状态。 From that state it may need to go through the onCreate()
method if the system has killed the process to release memory for apps in the foreground (or system processes, I suppose). 从该状态开始,如果系统onCreate()
了为前台应用程序(我想是系统进程)释放内存的进程,则可能需要通过onCreate()
方法。
There's a nice life-cycle diagram in Android documentation . Android文档中有一个不错的生命周期图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.