问题
I have two activities:
A: a Splash Screen
B: the Main activity
When the application starts, I show the splash screen with a short video then call B. I want the user to be able to close application with the back button in activity B. (The user shouldn't see splash screen again.)
回答1:
You can set android:noHistory="true" for the splash screen in the manifest. This will not add the activity to the back stack.
<activity
android:name="SplashScreen"
android:noHistory="true"
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
回答2:
In your splash screen call finish() when you start Activity B.
来源:https://stackoverflow.com/questions/10865415/closing-my-android-app-in-my-main-activity-on-back-pressed