1.onNewIntent
首先看一下Activity 的生命周期:
从图中可知,初次启动 Activity 时,调用顺序为:onCreate() -> onStart() -> onResume()
那么,onNewIntent() 是什么时候被触发的呢,它又有什么用呢?
让我们再来看一张图:
上面这张图直观的说明了 onNewIntent() 是什么时候被调用的。而且其中还表明了最重要的一点:onCreate() 和 onNewIntent() 不会被同时调用。
来看看官网是如何解释onNewIntent() 的:
void onNewIntent (Intent intent)
This is called for activities that set launchMode to “singleTop” in their package, or if a client used the FLAG_ACTIVITY_SINGLE_TOP flag when calling startActivity(Intent). In either case, when the activity is re-launched while at the top of the activity stack instead of a new instance of the activity being started, onNewIntent() will be called on