Skip to content

Use Android 12 splashscreen API #7337

@fiznool

Description

@fiznool

🚀 Feature

Android 12 has introduced a new SplashScreen API, with an AndroidX compat library for older versions. In a nutshell, this allows developers to hook up an animatable splash screen, and provides an API for dismissing the splash screen when the app is ready to be used.

If this library were to use the new SplashScreen API, apps using RNN could add splash screen support quite easily.

Motivation

From the Android docs:

If you do not migrate your app [to the new SplashScreen API], your app launch experience on Android 12 and higher will be either degraded or may have unintended results

Pitch

Changes to RNN codebase (mostly as per these Android docs):

  • compileSdkVersion should be set to 31.
  • 'androidx.core:core-splashscreen:1.0.0-alpha01' should be added as a dependency to build.gradle.
  • New documentation should be added to guide developers on adding the necessary splash screen assets.
  • The onCreate method in NavigationActivity.java should be updated as follows:
    • Install the splash screen: SplashScreen.installSplashScreen(this).

The splash screen will be automatically dismissed when the app draws its first frame, so providing this happens when the React Native side calls Navigation.setRoot, the splash screen will remain until this time.

Changes to documentation:

  • Section added on how to customise the Android splash screen. By default, the splash screen will consist of the launcher icon, centered in the screen, with a white background. This can be customised according to the Android docs, briefly the following needs to be done:
    • Create a new theme in android/app/src/main/res/values/styles.xml which extends Theme.SplashScreen
    • Add the necessary details here to customise the icon, animation etc.
    • Set the postSplashScreenTheme value to the main AppTheme
    • Update AndroidManifest.xml so that the MainApplication theme is this new splash theme
  • Section added on how to customise the exit animation of the splash screen, as per the Android docs

Are you willing to resolve this issue by submitting a Pull Request?

  • ✅   Yes, I have the time, and I know how to start.
  • ✖️   Yes, I have the time, but I don't know how to start. I would need guidance.
  • ✖️   No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions