主要活动在AndroidManifest.xml中通过以下方式指定:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
但是我不知道如何根据代码逻辑动态指定第一个活动。
指定一个默认的Activity,该逻辑包含在onCreate方法中启动所需的任何Activity的逻辑。
@Ian G's answer是正确的-但我认为可以通过从后堆栈中删除启动活动来改善他的位置。这就是@gardarh is trying to say。
我没有要添加注释的要点,但是在某些情况下,从后堆栈中删除启动器活动可能会很有用。这篇SO帖子介绍了如何执行此操作:Removing an activity from the history stack
Conditional navigation对您来说可能很有趣。