I have a Splash Screen activity that looks like this:
<activity
android:name=".activity.BoardingActivity"
android:configChanges="layoutDirection|locale"
android:exported="true"
android:label="@string/app_name"
android:noHistory="true"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Inside the BoardingActivity, I call the MainActivity once the animation is done.
Intent intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
In Samsung devices running Android 14, the startActivity function is causing the MainActivity to constantly create, destroy itself. The activities are getting created on different threads and new threads are being created even before the old ones are destroyed. The savedBundleState is always empty for the newly created activities. This is an infinite loop that keeps happening until the app crashes. It works normally in non-samsung devices running Android 14.
Any help or advice is appreciated.
I have tried changing the launch activity to a different activity but the same thing happens when I call startActivity. I have also changed the launchMode to singleTask or singleTop but neither of them worked.
Starting from Android 12, there is a new and recommended way to implement Splash Screen now