Splash the new way: SplashScreen API

You must have come across Splash Screens on mobile apps, both as a user and as a mobile developer. During my early days as a mobile developer, I mostly frowned at the thought of implementing a Splash Screen. However, after using many apps, reading about the mobile platforms, how they worked, how the mobile apps are loaded, it gradually seemed to make sense why “Splash Screens” are necessary.

Here’s a link to a well written article that talks about the history of Splash Screens, what was the motivation for using them and also details out some best practices for implementing Splash screens.

Splash screens: Designing a welcome experience users adore

By Kieran Tie, invision

To summarise, Splash Screens do enhance the experience. We could see this in many popular apps. More so, in apps that are not native, which are built with cross-platform or hybrid mobile app frameworks like Flutter, Ionic, React Native etc. where the initial app loads does take a considerable amount of time. Compared to a white/blank screen, it’s a better idea to show a meaningful splash screen which keeps the user interested and engaged.

The purpose of this write up is to introduce the brand new “SplashScreen API” that is introduced in Android 12. Although it is still in preview, it’s quite interesting.

To implement a Splash Screen on Android 12 powered devices, you don’t need to write a single line of code. 👌

Just migrate to “compileSDKVersion” to “android-S”, and “targetSDKVersion” to S. These values will of course change when we have the final Android 12 release. You might have to delete your old Splash Screen implementations to take advantage of this new and standard API.

Word of caution: I am not sure if this would be backward compatible with older API levels though.

compileSdkVersion "android-S"
...
defaultConfig {
...
targetSdkVersion "S"

That’s it. You already get a default implementation of a Splash Screen, which uses your app icon by default, and looks something like this.

New SplashScreen API

If you would like to customise the splash screen, the API provides various ways to customise or override the following:

  1. Change background colour (Default is white)
  2. Change the icon (Default is the application’s launcher icon)
  3. Make the icon animated (By using a AnimationDrawable or AnimationVectorDrawable)
  4. Set the screen animation duration (Maximum value: 1000ms)
  5. Set a branding image on the bottom of the Splash screen (a drawable resource)

You can find more details about this new API here.

While my phone and the laptop is being charged, I love to write, cook and ride away from the city on my bicycle.