skip to Main Content

I have recently changed my Target SDK Version to 31 (Android 12) and after upgrading I started getting this warning:

The application should not provide its own launch screen.

This is the screenshot:

enter image description here

Is there any better approach to create Splash Screens?

NOTE:
I know it is just a warning and can be ignored but I’m asking for now recommended way to create Splash Screens.

4

Answers


  1. There is better approach now. For Android 12, there is brand new Splash Screen Api which works on previous versions aswell, see more here

    It supports theming, custom animations and is super simple to use.

    Login or Signup to reply.
  2. Just change the name, without using "splash" in it.

    Login or Signup to reply.
  3. 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()
            ...
    
    Login or Signup to reply.
  4. You also can suppress it using this @SuppressLint("CustomSplashScreen"):

    @SuppressLint("CustomSplashScreen")
    public class SplashActivity extends AppCompatActivity {
        ...
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search