First of all, pre-defined in The AndroidManifest, set icon, set enabble to false to disable, and point to the original SplashActivity

<activity android:name=".SplashActivity">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

<! --Activity alias, which must be built into the APP -->
<activity-alias
	<!--thisActivityClasses may not necessarily exist-->
    android:name=".SplashAliasActivity"
    android:enabled="false"
    <! -- define holiday icon here -->
    android:icon="@mipmap/ic_launcher_spring_festival"
    android:targetActivity=".SplashActivity">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity-alias>
Copy the code

When the APP is running in the background, replace the icon (set enable to true) and disable the original component. You can use WorkManager to set automatic tasks

// Omit the scheduled task code (see WorkManager) and set the scheduled toggle icon
// Disable the original icon
val oldActivity = ComponentName(applicationContext, SplashActivity::class.java)
applicationContext.packageManager.setComponentEnabledSetting(oldActivity, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP)
// Enable the new icon
val newActivity = ComponentName(applicationContext, "Your.Full.PackageName.SplashAliasActivity")
applicationContext.packageManager.setComponentEnabledSetting(newActivity, PackageManager.COMPONENT_ENABLED_STATE_ENABLED,PackageManager.DONT_KILL_APP)
Copy the code