The newly introduced Splash Screen feature on Android 12 can effectively create free and rich application launch effects. But what about the lower version devices that still dominate the market? The answer is the SplashScreen library, a new member of Jetpack. Let’s take a look at how it works and how it works!

preface

As early as when Android 12 Preview version was released, I noticed the cool Splash Screen feature, so I quickly customized and shared various startup effects created by it, and received a lot of positive feedback. What a great honor: the Google engineer in charge of Splash Screen also liked my Demo and forwarded it!

However, many developers say that while Android 12 works well, pre-12 versions are the mainstream, and it would be silly if they weren’t compatible. Everyone, including me, was concerned about how the new feature would work in the lower version.

While scrolling through the Google engineer’s historical tweets, I came across an API called SplashScreen that had just come out of the AndroidX package. We all know that AndroidX belongs to Jetpack, which is a set of development frameworks independent of the SDK version, and it’s clearly designed to work with the Splash Screen feature library, which is a lower version.

This is timely, we must study it and make Splash Screen function fully play its role! In addition to the previous shared article did not mention the implementation principle, this article discusses together.

1. New member SplashScreen

Jetpack SplashScreen is a development library that is backward compatible with the Android 12 SplashScreen feature. Its earliest support for Android 6 (API 23), the global Android devices 6 and above occupy more than 90%, can be said to be fully adequate.

1.1 Functions and limitations

The Splash Screen created by Splash Screen is divided into two parts: approach and exit. The former is responsible for displaying basic information such as Icon, Icon animation and brand Logo, while the latter is used to show the animation effect of the whole or Icon view transition to the target Screen.

For the exit section, the Jetpack SplashScreen library works as well as Android 12 whether it’s running on 12 or not; However, the entry section has some temporary limitations if it is running on a lower version.

  • Display of Icon animation is not supported:AnimatedVectorDrawable
  • Icon background is not supported currently:IconBackgroundColor
  • Setting the brand Logo is not supported:BrandingImage
Function comparison of the entry section The Jetpack version The Android version 12
ScreenBackground YES YES
ScreenIcon YES YES
AnimatedVectorDrawable NA YES
IconBackgroundColor NA YES
BrandingImage NA YES

Note: The implementation of the SplashScreen library will be covered later, but the entry effect for earlier versions is essentially a LayerDrawable. To be honest, there is no way to support Vector Drawable animation, Adaptive Icon backgrounds. But I think it can be perfectly supported by adding some extra processing at the code level. I look forward to improving it in the later upgrade!

2.2 Importing Dependencies

The latest version of the SplashScreen library is 1.0.0-Alpha01, which is simply dependent on Gradle.

dependencies {
    def core_version = "1.6.0".// Optional - APIs for SplashScreen, including compatiblity helpers on devices prior Android 12
    implementation "Androidx. Core: the core - splashscreen: 1.0.0 - alpha01"
}
Copy the code

2.3 SplashScreen Library preset themes

SplashScreen library on the splash screen defines the special Attr, such as setting up background windowSplashScreenAnimatedIcon and windowSplashScreenBackground Icon and pictures, And postSplashScreenTheme for setting the Activity theme after the startup screen exits.

Low version does not support the Icon animation, there would be no configuration length, but the library is to provide the related attributes windowSplashScreenAnimationDuration, why don’t know much about it.

<attr format="reference" name="postSplashScreenTheme"/>
<attr format="reference" name="windowSplashScreenAnimatedIcon"/>
<attr format="integer" name="windowSplashScreenAnimationDuration"/>
<attr format="color" name="windowSplashScreenBackground"/>
Copy the code

In addition, in order to simplify the configuration of the App, the theme is preset and the device version is differentiated.

Here are the themes for the lower version:

<style name="Theme.SplashScreen" parent="Theme.SplashScreenBase">
    <item name="postSplashScreenTheme">? android:attr/theme</item>
    <item name="windowSplashScreenAnimationDuration">@integer/default_icon_animation_duration</item>
    <item name="windowSplashScreenBackground">@android:color/background_light</item>
    <item name="windowSplashScreenAnimatedIcon">@android:drawable/sym_def_app_icon</item>
</style>

<style name="Theme.SplashScreenBase" parent="android:Theme.NoTitleBar">
    <item name="android:windowBackground">@drawable/compat_splash_screen</item>
    <item name="android:opacity">opaque</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:fitsSystemWindows">false</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
    <item name="android:navigationBarColor">@android:color/transparent</item>
</style>
Copy the code

Crucially, the parent theme SplashScreenBase sets the windowBackground property, which points to the Drawable responsible for showing the earlier version of the splash screen.

The principle is simple: Read windowSplashScreenBackground ColorDrawable and windowSplashScreenAnimatedIcon Settings icon set in the Drawable, The Drawable icon is placed in the center of the background Drawable and then combined to form the Layer Drawable. To be honest, it’s similar to the way we used to customize the splash screen.

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:gravity="fill">
        <color android:color="? attr/windowSplashScreenBackground" />
    </item>
    <item
        android:drawable="? attr/windowSplashScreenAnimatedIcon"
        android:gravity="center"
        android:width="@dimen/splashscreen_icon_size"
        android:height="@dimen/splashscreen_icon_size" />
</layer-list>
Copy the code

Since version 12 provides the system property of Splash Screen function, for themes 12 and above, only the properties defined by the library need to be transformed into system properties.

<style name="Theme.SplashScreen" parent="android:Theme.DeviceDefault.NoActionBar">
    <item name="android:windowSplashScreenAnimatedIcon">? windowSplashScreenAnimatedIcon</item>
    <item name="android:windowSplashScreenBackground">? windowSplashScreenBackground</item>
    <item name="android:windowSplashScreenAnimationDuration">? windowSplashScreenAnimationDuration</item>
</style>
Copy the code

2. Create an entry effect

Adapting the new API on top of the original Demo feels like a lack of novelty. Flappy Bird, which was recreated in Jetpack Compose, didn’t have time to design a SplashScreen, so this time, I’ll use Jetpack’s SplashScreen library to improve it.

2.1 Prepare animated ICONS

Flappy Bird’s Logo is a Bird, currently only a PNG, to customize the Icon animation effect to convert to SVG.

After searching for many tools, I finally found a website that can transform PNG to SVG perfectly: it supports adding and removing various color areas, thus restoring each color block, each Path to the maximum extent possible.

www.pngtosvg.com/

Using the Vector Asset Tool and Animated Vector Drawable tags that come with AS, you can extend SVG into a Vector animation file with formatted effects.

<animated-vector .>
    <aapt:attr name="android:drawable">
        <vector
            android:width="400dp"
            android:height="404.73373 dp"
            .>
            <group
                android:name="BirdGroup"
                android:pivotX="200"
                android:pivotY="202"
                android:rotation="0">
                <path
                    android:fillColor="# 503745"
                    android:fillType="evenOdd"
                    android:pathData="M173.7, C173.419 133.065, 133.178..."
                    android:strokeColor="# 00000000" />.</group>
        </vector>
    </aapt:attr>

  <target android:name="BirdGroup">
    <aapt:attr name="android:animation">
      <set>
        <objectAnimator
            android:duration="@integer/icon_animator_duration"
            android:interpolator="@android:anim/decelerate_interpolator"
            android:propertyName="translateX"
            android:valueFrom="@integer/icon_animator_translate_from"
            android:valueTo="@integer/icon_animator_translate_to" />.</set>
    </aapt:attr>
  </target>

</animated-vector>
Copy the code

2.2 Adaptation Theme

On Android 12, specify the Splash Screen properties for the entry Activity to achieve the entry effect. The SplashScreen library is the same idea, but to simplify the code, we can configure the Activity library with a preset theme.

Since the App side has to specify unique resources for these properties, the theme needs to be simply extended and version-specific. If you happen to support Android 6 at the earliest, you will need to configure the default theme and the values -V31 theme for 12, otherwise you will need to configure the values-23 theme for 6-11.

The default Theme must be extended from the default Theme.SplashScreen, overriding the Icon, Duration, and ScreenBackground properties. Because some of the attributes of the 12-oriented topic are consistent with the default topic, the common parts are extracted into Base for reuse.

<style name="JetpackSplashTheme" parent="JetpackSplashTheme.Base">
</style>

<style name="JetpackSplashTheme.Base" parent="Theme.SplashScreen">.<item name="windowSplashScreenAnimatedIcon">@drawable/ic_icon_bird_small_animated_translate</item>
    <item name="windowSplashScreenAnimationDuration">@integer/icon_animator_duration</item>
    <item name="windowSplashScreenBackground">@color/appBackground</item>

    <item name="postSplashScreenTheme">@style/SplashActivityTheme</item>
</style>

<style name="SplashActivityTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
    <item name="colorPrimary">@color/purple_500</item>
    <item name="colorPrimaryDark">@color/purple_700</item>
    <item name="colorAccent">@color/teal_200</item>
</style>
Copy the code

Note that it is a good idea to specify the postSplashScreenTheme property. Since the SplashScreen class is required for subsequent customization effects, it will strictly check the configuration that requires this property, otherwise Crash will occur.

Cannot set AppTheme. No theme value defined for attribute postSplashScreenTheme.

In addition, most activities generally inherit from the Activities provided by the AppCompat framework, which requires that the screen be configured with an AppCompat theme. In other words, the postSplashScreenTheme property must not only be specified, it must also be an AppCompat theme!

Note: The reason for this limitation of the AppCompat framework can be seen in the previous article “In-depth understanding of the Foundation of the Jetpack Framework -AppCompat”.

You need to use a Theme.AppCompat theme!

By reusing the common theme, a theme for 12 only needs to specify the Icon background attribute IconBackgroundColor and the brand Logo attribute BrandingImage.

<style name="JetpackSplashTheme" parent="JetpackSplashTheme.Base">
    <item name="android:windowSplashScreenIconBackgroundColor">@color/skyBlue</item>
    <item name="android:windowSplashScreenBrandingImage">@drawable/ic_tm_brand_newer</item>
</style>
Copy the code

Here’s the splash screen entry on Android 8.1 and 12, respectively, with the bird coming in from the left and zooming in.

For example, the bird rotates to enlarge the animation.

In fact Animated Vector Drawable supported by a Path animation more cool and flexible, can create a richer experience of animation, you can try it!

2.3 Optimized the lower version of the approach Icon

By comparison, it can be seen that there is no Icon animation, Icon background and brand Logo in the entry effect of 8.1. In order to be as close as possible to the approach effect of 12, you can change the Icon attribute of the theme of the earlier version to Adaptive Icon, and use animated Icon only for the theme facing 12.

<! -- Default theme: For versions prior to 12 -->
<style name="JetpackSplashTheme" parent="JetpackSplashTheme.Base">
    <! -- Adaptive icon drawable -->
    <item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher_bird_final</item>
</style>

<! -- Version for 12 -->
<style name="JetpackSplashTheme" parent="JetpackSplashTheme.Base">
    <! -- Animated vector drawable -->
    <item name="windowSplashScreenAnimatedIcon">@drawable/ic_icon_bird_small_animated_translate</item>.</style>
Copy the code

3. Extend the splash screen

3.1 Obtaining the SplashScreen Customization Entry

These themes are configured to achieve the entry effect, but in order to further control the SplashScreen or customize the exit effect, you need to obtain the entry of control, the SplashScreen class. The SplashScreen library provides installSplashScreen().

class MainActivity : ComponentActivity() {
    private val viewModel: GameViewModel by viewModels()

    override fun onCreate(savedInstanceState: Bundle?).{...// Need to be called before setContentView or other view operation on the root view.
        val splashScreen = installSplashScreen()

        setContent { ... }
        
        SplashScreenController(splashScreen, viewModel).apply {
            customizeSplashScreen()
        }
    }
}
Copy the code

One thing to note: InstallSplashScreen () must be called before setContentView() because the install function gets the theme specified by the postSplashScreenTheme property and setThe theme to the Activity after the check passes.

To be clear, the install function only performs the initialization of the theme and resources, and the exit view has not yet been loaded.

3.2 Control the display duration of the splash screen

When the first frame of the App starts drawing, the Splash Screen Window will exit. If the drawing has started, but some key logic is not completed, this will affect the full presentation. At this point we can extend the splash screen appropriately and let the user wait a little longer.

Android 12 does not provide an API to control startup time. The previous Demo did this by registering an OnPreDrawListener callback hang trace with the ContentView. (Hanging the drawing indirectly causes the delayed exit of the Splash Screen Window, thus extending the Splash Screen.)

The SplashScreen library provides a dedicated API to handle this requirement, known as KeepOnScreenCondition. We need to tell SplashScreen the conditions that require continuous display, and WMS will maintain its display until the conditions are broken. In fact, the implementation of the API is the same as before.

class SplashScreenController(...). {fun customizeSplashScreen(a) {
        keepSplashScreenLonger()
        ...
    }

    // Keep splash screen showing till data initialized.
    private fun keepSplashScreenLonger(a){ splashScreen.setKeepVisibleCondition { ! viewModel.isDataReady() } } }Copy the code

You can see that the splash screen takes longer.

4. Customize exit effects

In order to make a perfect transition from the splash screen to the target screen, the customization of the exit effect is particularly important. In addition, compared with the approach can only customize Icon animation, exit can customize the whole and all kinds of Icon animation, more space and more flexible.

4.1 Execute exit animation

When the Splash Screen Window exits, it is the time to execute the exit animation. This time is available through the OnExitAnimationListener API provided by the SplashScreen library, which also returns a SplashScreen view for subsequent customization.

Unlike Android 12, the SplashScreen library SplashScreen view is encapsulated in the SplashScreenViewProvider. The API returns a view based on the version: the early version is the custom FrameLayout, and the 12 is the version-specific SplashScreenView.

fun customizeSplashScreen(a){... customizeSplashScreenExit() }// Customize splash screen exit animator.
private fun customizeSplashScreenExit(a) {
    splashScreen.setOnExitAnimationListener { splashScreenViewProvider ->
        val onExit = {
            splashScreenViewProvider.remove()
        }
        showSplashExitAnimator(splashScreenViewProvider.view, onExit)
        showSplashIconExitAnimator(splashScreenViewProvider.iconView, onExit)
    }
}
Copy the code

The unified SplashScreenViewProvider instance allows you to perform consistent animations regardless of which version you are running.

For example, zooming and fading the whole view.

private fun showSplashExitAnimator(splashScreenView: View, onExit: () -> Unit = {}) {
    val alphaOut = ObjectAnimator.ofFloat(
        splashScreenView,
        ...
    )

    val scaleOut = ObjectAnimator.ofFloat( ... )

    AnimatorSet().run {
        duration = defaultExitDuration
        interpolator = AnticipateInterpolator()
        playTogether(scaleOut, alphaOut)
        start()
    }
}
Copy the code

Animate zoom, fade, and shift for Icon views. The goal is for the bird to gradually shrink and move up into the game screen, a seamless transition into the game area.

private fun showSplashIconExitAnimator(iconView: View, onExit: () -> Unit = {}) {
    val alphaOut = ObjectAnimator.ofFloat(
        iconView,
        ...
    )
    val scaleOut = ObjectAnimator.ofFloat( ... )
    val slideUp = ObjectAnimator.ofFloat( ... )

    AnimatorSet().run {
        ...
        playTogether(alphaOut, scaleOut, slideUp)
        doOnEnd {
            onExit()
        }
        start()
    }
}
Copy the code

Note: Be sure to manually remove the view by calling remove() after the exit animation, otherwise you may see that the splash screen is always covered over the App and cannot disappear. In the case of 12, this is actually the system returning the SplashScreenView Surface remaining on the screen, and in the earlier version the FrameLayout remaining in the ContentView tree.

4.2 Optimize the duration of exit animation

When the App starts drawing, Splash Screen Window will exit and execute the preset exit animation regardless of whether the incoming animation is finished. The performance of the equipment or the different load state will affect the start time of App drawing, so the execution time of exit animation is not fixed, and slightly changes with the condition of the equipment.

  • If the App draws early, the entry animation may not be executed yet. In order for the user to see the target content more quickly, the exit animation can shorten the execution time, such as using the remaining time of the enter animation directly

  • On the other hand, if you draw late, the entry animation will be over. If the exit animation takes up any more time, it will seriously delay the user from seeing the target content, resulting in a bad impression of a startup lag. So at this point, the exit animation can be executed for a very short fixed time, or not at all

In other words, the original intention of exit animation is to buffer and transition the background loading. The startup experience can not be sacrificed for the sake of showing the animation, but the duration of exit can be flexibly controlled.

To make it easy to calculate the remaining duration of an Icon animation in play, the SplashScreen library provides apis to get its start time and total duration:

/** * Start time of the icon animation. * * On API 31+, returns the number of millisecond since the Epoch time (1970-1-1T00:00:00Z) * * Below API 31, returns 0 because the icon cannot be animated. */
public val iconAnimationStartMillis: Long get() = impl.iconAnimationStartMillis

/** * Duration of the icon animation as provided in attr. */
public val iconAnimationDurationMillis: Long get() = impl.iconAnimationDurationMillis
Copy the code

The following code demonstrates how to determine whether the enter animation is finished before the exit animation is executed. If it is finished, use the remaining time of the animation, otherwise abandon the execution.

private fun getRemainingDuration(splashScreenView: SplashScreenViewProvider): Long {
    // Get the duration of the animated vector drawable.
    val animationDuration = splashScreenView.iconAnimationDurationMillis

    // Get the start time of the animation.
    val animationStart = splashScreenView.iconAnimationStartMillis

    // Calculate the remaining duration of the animation.
    return if (animationDuration == 0L || animationStart == 0L)
        defaultExitDuration
    else (animationDuration - SystemClock.uptimeMillis() + animationStart)
        .coerceAtLeast(0L)}Copy the code

As mentioned earlier, the lower version does not support Icon animation when entering, so there is no need to calculate the remaining time. So on earlier versions, both apis always return the default value of 0, so be aware!

private open class ViewImpl(val activity: Activity) {
    open val iconAnimationStartMillis: Long get() = 0
    open val iconAnimationDurationMillis: Long get() = 0. }Copy the code

5. Implementation principle of SplashScreen

The source code for Android 12 is not publicly available, but the source code for the Jetpack SplashScreen library is read below. ※ I thought the API provided by SplashScreen library was simple and straightforward, and the principle should not be complicated. But after digging into the source code, found that there are many details and speculation, or it is worth thinking about.

5.1 Overall Architecture

An Activity gets access to the SplashScreen through the SplashScreen instance provided by the SplashScreen library. Depending on the OS version, the Activity’s interior will display, delay, or remove the SplashScreen using the 12-specific API or a custom view.

5.2 installSplashScreen

InstallSplashScreen (), which gets the SplashScreen instance, reads and sets the Theme for the target Activity. If running on an earlier version, you also need to get the Icon and Background configuration. At this point it is just fetching, not adding a custom view for exit.

5.3 setKeepVisibleCondition

SetKeepVisibleCondition () extends the display of the splash screen, regardless of the running version, by registering an OnPreDrawListener callback to the ContentView’s ViewTreeObserver. When the release is marked, the earlier version needs to manually execute the exit callback, while the 12 version is executed by the system itself.

The custom view for exiting the Splash Screen Window is still not added, but the exit of the Splash Screen Window is delayed.

5.4 setOnExitAnimationListener

SetOnExitAnimationListener () can monitor exit timing, SplashScreen will splash screen view ready to encapsulate to SplashScreenViewProvider, then in the splash screen need to quit, Callback via the OnExitAnimationListener interface.

View related handling is frequent on older versions, so you inflate a custom layout and add it to the ContentView, which then reflects the background and icon prepared by the install.

Custom layouts added for earlier releases:

<FrameLayout .>

  <ImageView
      android:id="@+id/splashscreen_icon_view"
      android:layout_width="@dimen/splashscreen_icon_size"
      android:layout_height="@dimen/splashscreen_icon_size"
      android:layout_gravity="center" />

</FrameLayout>
Copy the code

5.5 adjustInsets this operation is special

When SplashScreenViewProvider is initialized, it makes an extra call to adjustInsets(), and the specific logic is only implemented for earlier versions. Let’s see what this particular treatment means.

Let’s start with the function comment:

Adjust the insets to avoid any jump between the actual splash screen and the SplashScreen View.

To avoid jumping between the splash screen and the SplashView view, you need to adjust the parameters of the lower view. It seems that it is not very understandable, and then combined with the specific implementation of the function:

private class Impl23(activity: Activity) : Impl(activity) {
    override fun adjustInsets(
        view: View,
        splashScreenViewProvider: SplashScreenViewProvider
    ) {
        // Offset the icon if the insets have changed
        val rootWindowInsets = view.rootWindowInsets
        val ty =
            rootWindowInsets.systemWindowInsetTop - rootWindowInsets.systemWindowInsetBottom
        splashScreenViewProvider.iconView.translationY = -ty.toFloat() / 2f}}Copy the code

The default adjustInsets() have no implementation, only the earlier versions have an implementation. Why is that?

The handling is straightforward: Listen for changes to the layout of the View stored in the SplashScreenViewProvider, get the rootWindowInsets from it, midpoint the height difference between the status bar and the navigation bar overlaid on the Window, and move the Icon View up or down.

  • The previous principle mentioned that the lower version of the approach effect actually sets a Layer Drawable toWindow BackgroundIn the Drawable, the Icon is centered, so the Icon is also completely centered in the Splash Screen Window
  • The exit view is not the Window Background Drawable, but is manually added to the ContentViewFramelayoutLayout. For the layout, the Icon view is centered, but for the Window to which it belongs, because the Statusbar at the top and the NavigationBar at the bottom are different heights, the final Icon view is not completely centered in the Window overall position. Especially when the equipment is usedGesture NavigationIn navigation mode, the Icon view is more down
  • The exit view is a complete copy of the Splash Screen Window. It is not a custom sublayout of the ContentView

To sum up, if no intervention, the Icon of the App will be misplaced or jump when the Window Background enters the arena and the FrameLayout exits the arena.

5.6 remove

SetOnExitAnimationListener call, SplashScreen library will splash screen view of callback back, after perform an animation you need to call remove () manually remove view, its principle is simple:

  • Remove FrameLayout from the ContentView tree
  • 12 is calling a dedicated API called SplashScreenView#remove()

6. The API

Here are some key apis for the SplashScreen library:

API instructions
SplashScreen The Jetpack edition gets a class for custom splash screen entry
Activity#installSplashScreen() Override Activity to get a static member function for a custom entry
setKeepVisibleCondition Specifies conditions to keep the splash screen on display
KeepOnScreenCondition Implement the interface for displaying conditions
setOnExitAnimationListener Listen for startup screen exit time
OnExitAnimationListener Splash screen exit callback interface
SplashScreenViewProvider Customize the splash screen view for exit effects

Here’s a quick comparison to what Android 12 offers:

Attr contrast The Jetpack version The Android version 12
Specify the target Activity theme postSplashScreenTheme
Specify animation Icon windowSplashScreenAnimatedIcon android:windowSplashScreenAnimatedIcon
Specifies the splash screen background windowSplashScreenBackground android:windowSplashScreenBackground
Specifies the duration of Icon animation windowSplashScreenAnimationDuration android:windowSplashScreenAnimationDuration
Specify Icon background android:windowSplashScreenIconBackgroundColor
Designated Brand Logo android:windowSplashScreenBrandingImage
API contrast The Jetpack version The Android version 12
Splash screen custom entry class androidx.core.splashscreen.SplashScreen interface android.window.SplashScreen
Entry instance acquisition Activity#installSplashScreen() Activity#getSplashScreen()
Splash screen view SplashScreenViewProvider SplashScreenView

7. The Demo in this paper

Open source address: github.com/ellisonchan…

Splash Screen for Compose Flappy Bird

8. Pending matters

From the above explanation, we know that the splash screen showing the exit effect on the previous version is essentially a temporary FrameLayout added to the App. This is not the case on Windows 12, and the Dump command shows that no additional Windows are created when exiting.

  • So what is the SplashScreenView that gives the App a customized exit effect when the Window exits?
  • If the “View” doesn’t belong to the App itself, then the App can access it and make changes to the properties. How does that work?

When I decided to put this doubt aside, I happened to find that system logs related to Splash keywords would be printed during the execution of the Splash screen on next 12:

StartingSurfaceDrawer: addSplashScreen com.ellison.flappybird: nonLocalizedLabel=null theme=7f1000e7 task= 334 StartingSurfaceDrawer: window attributes color: ffecfcdd icon android.graphics.drawable.AnimatedVectorDrawable… StartingSurfaceDrawer: fillViewWithIcon surfaceWindowView android.window.SplashScreenView… StartingSurfaceDrawer: Copying splash screen window view for task: 334 parcelable? android.window.SplashScreenView$SplashScreenViewParcelable StartingSurfaceDrawer: Task start finish, remove starting surface for task 334 StartingSurfaceDrawer: Removing splash screen window for task: 334

StartingSurfaceDrawer is responsible for reading, displaying, and removing the Splash Screen Window view set by your App through WMS. Before the Window exits, notify the target Activity’s PhoneWindow through WMS, restore the view from the SplashScreen Window, and then add the restored SplashScreenView to the App Screen. Because PhoneWindow holds the DecorView directly, it can be attached directly to the DecorView.

The details of who StartingSurfaceDrawer is, whether it is correct, and whether it is correct, will be studied in more detail when the source code is released in 12 months

conclusion

It was initially speculated that the decision was made to make the SplashScreen library the first to be compatible with Android 6 and above as it became more mainstream in the market. When I looked into the principles later, I found that the adjuinSets () handling that was called internally depended on an API that was only added in Version 6, so IT felt like that was the real reason for the compatibility in 6.

It doesn’t matter whether the compatibility with Android 6 is due to occupancy considerations or API limitations, the Splash Screen feature already supports a large enough number of Android devices.

You said earlier that Android 12’s new Splash Screen feature is cool, but it’s not compatible with older versions. Now hasJetpack SplashScreenThe blessing of library, the total match?

The resources

SplashScreen document

A peek inside Jetpack Core Splashscreen

Meet the Jetpack Splashscreen API: a definitive guide for splash screens in Android

Recommended reading

The new app splash screen on Android 12.

Compose a perfect replica of Flappy Bird!

A look at Jetpack in terms of Preference component changes

An in-depth look at AppCompat, the cornerstone of the Jetpack framework