onStart of new Activity is called before onStop of parent

这一生的挚爱 提交于 2019-12-03 06:28:49

问题


I've got an application. I use startActivity() to start activity.

Can anyone actually tell me why system is calling onStart() of new Activity first, instead of parents onStop()? Is that even possible (without system bug)?

I've found Fragment onStop() being called directly after onStart() - WHY? answer, but I got nothing in common with Fragments and using android-support library. I'm stuck because I'm using RoboSpice and it must contain proper, synchronized methods in onStart and onStop. I can't because system is calling it in wrong order.

I'm using GCM and Analytics libraries as well in this application.


回答1:


If you have a read of the Activity Lifecycle documentation onStop is only called when the current activity is replaced by a new (or previous) one.

For that to happen the other application has to start or resume... otherwise there would be a gap

onPause of the current activity is (I would expect) called before the onStart of the replacing Activity



来源:https://stackoverflow.com/questions/17214452/onstart-of-new-activity-is-called-before-onstop-of-parent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!