user999822
user999822

Reputation: 445

Closing my Android app in my main activity on back pressed

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.)

Upvotes: 0

Views: 1212

Answers (2)

Jereld
Jereld

Reputation: 162

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>

Upvotes: 4

Tarun
Tarun

Reputation: 13808

In your splash screen call finish() when you start Activity B.

Upvotes: 2

Related Questions