This is a companion discussion topic for the original entry at https://www.kodeco.com/39828426-your-first-kotlin-android-app-polishing-the-app/lessons/25
This is a companion discussion topic for the original entry at https://www.kodeco.com/39828426-your-first-kotlin-android-app-polishing-the-app/lessons/25
To get the splash screen working on an older Android version like 7 (version 24).
The android:theme="@style/Theme.CustomSplashScreenTheme"
should only be applied to the MainActivity
not Application
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.BulllsEye"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:screenOrientation="landscape"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.CustomSplashScreenTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
``
Thanks for your comment. I really appreciate your feedback.
However, applying the custom theme on the starting Activity
in this case the MainActivity
node still has the same effect. This means that you can apply it on either the starting activity or on the application node. I prefer the application node since this is the root of the AndroidManifest.xml
file.
Remember, we set the postSplashScreenTheme
to @style/Theme.Bullseye
so everything should revert back to normal after the splash screen is shown.
You can read more about this from the Android documentation here.
Multiple people from the bootcamp class tried the root of the AndroidManifest.xml
It works fine on my phone which is Android 12 and on an emulator running Android 13
but no splash screen for older SDK’ Android 7 (version 24) and android 8 (version 26)
Maybe we are doing something wrong
Just downloaded and tested the final project, it will not work on Android 10 unless I move CustomSplashScreenTheme from Application Node to Activity Node.
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Bullseye"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:theme="@style/Theme.CustomSplashScreenTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
O okay. Remember i mentioned in that the app has to be terminated then opened from the launcher if running on Android versions prior to Android 12. They should make sure they do that then if it persists it simply means that’s a bug with the library and moving it to the activity node should be the fix as you suggested.
It appears to be a bug. I attempted to test it by terminating the app and then opening it from the launcher, but it still doesn’t display a splash screen. Unless I move CustomSplashScreenTheme from the Application Node to the Activity Node.
I’ve updated the student material and author note of this episode for future students.
Thanks so much.