Android 启动模式单任务

Android Launch Mode Single Task

在我的应用程序中,我有一个仪表板 activity,它的启动模式是 "SingleTask" 我的应用程序是否有可能在没有 onCreate 的情况下进入 onNewIntent?

例如,如果用户从仪表板导航到另一个 activity,并且在仪表板被销毁后,如果用户再次导航到仪表板会发生什么?

onCreate 会起作用还是只会从 onNewIntent 继续?

谢谢。

根据 Android API 文档,onNewIntent 只会被调用:

activities that set launchMode to "singleTop" in their package, or if a client used the FLAG_ACTIVITY_SINGLE_TOP flag when calling startActivity(Intent).

由于您使用的是 SingleTask,因此不应调用 onNewIntent

参见:https://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Intent)