Ashutosh
Ashutosh

Reputation: 4675

ANDROID: SPLASH: Why I always see splash screen when app is resumed

I just created my first proper android app and ran into the splash screen issue. Whenever my app comes into foreground, splash screen is displayed first and then the last opened activity is shown. The resume feature looks fine but why the splash screen is always showed. In other apps, I don't see such behavior. Here is my code:

minSdkVersion 24
targetSdkVersion 26

I used android:noHistory="true" but still no changes I tried intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); but still no change

From AndroidManifesh.xml

<activity
        android:noHistory="true"
        android:label="@string/app_name"
        android:name=".activities.SplashActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:noHistory="true"
        android:configChanges="keyboardHidden"
        android:name=".activities.MainActivity" />

From SplashActivity.java

Handler handler;

@Override
public void onCreate(Bundle savedInstanceState) {
            handler = new Handler();
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    Intent intent = new Intent(SplashActivity.this, MainActivity.class);

                    startActivity(intent);
                    finish();
                }
            }, Constant.SPLASH_SCREEN_TIMEOUT);
}

What am I missing? Any more code is required for explanation?

Upvotes: 0

Views: 2170

Answers (1)

Quick learner
Quick learner

Reputation: 11457

Remove this android:noHistory="true" from all the activities.

A value of "true" means that the activity will not leave a historical trace. It will not remain in the activity stack for the task, so the user will not be able to return to it

Upvotes: 2

Related Questions