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?
RegistrationPhoneNumberActivitytoSplashActivityby clicking back button, you should overrideonBackPressed()inRegistrationPhoneNumberActivityand then callfinish()inside it. - Mohammed Farhan