Starting in Android 12, the SplashScreen API enables a new app launch animation for all apps when running on a device with Android 12 or higher. This includes an into-app motion at launch, a splash screen showing your app icon, and a transition to your app itself.
TLDR; Android provides a new API for integrating SplashScreen.
First, remove the SplashScreen then follow below code block.
Add in build gradle
implementation 'androidx.core:core-splashscreen:1.0.0-rc01'
follow the below steps.
Define:
<style name="Theme.App.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/ed_colorPrimary</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_logo</item>
<item name="windowSplashScreenAnimationDuration">200</item>
<!-- Set the theme of the Activity that directly follows your splash screen. -->
<!-- Required -->
<item name="postSplashScreenTheme">@style/Theme.MyAppTheme</item>
</style>
Then in Manifest check and verify that you given Theme.App.Starting
<application
...
android:theme="@style/Theme.App.Starting" >
...
<activity
android:name=".ui.MainActivity"
android:exported="true"
android:label="@string/app_name"
android:launchMode="singleTask"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Finally, Don't forget to add.
class MainActivity : BaseActivity() {
private lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val splashScreen = installSplashScreen()
...