How to show OS splash screen on startup of a Compose Multiplatform app?

JVM (Java/Kotlin) apps take a little time to start and be presented to the user.

There may be various “tricks” to show a splash screen when the app is being loaded.

My main purpose for displaying a splash screen is to show some indication that the app is being launched.
So, for example, starting an launcher Java process to show an artificial splash screen may defeat the purpose because it itself may take some time to appear on the screen.

So, how can I take advantage of the OS native splash screens while my app has not yet appeared on the screen?

It seems Java supports showing operating system native splash screen while the app is being started.

I only tested it on Windows and it worked as expected.

So, in my project build.gradle(.kts) I added this:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>compose.desktop {
application {
nativeDistributions {
appResourcesRootDir = rootDir.resolve("myAssets")
// ...
}
// The image path is relative to the app (Java) working directory
// which is the app installation root directory (where the .exe file resides)
jvmArgs += "-splash:app/resources/myImage.gif"
// To make it work whatever is the working directory when invoking the app use:
// jvmArgs += "-splash:${'$'}APPDIR/resources/splash.png"
// ...
}
}
</code>
<code>compose.desktop { application { nativeDistributions { appResourcesRootDir = rootDir.resolve("myAssets") // ... } // The image path is relative to the app (Java) working directory // which is the app installation root directory (where the .exe file resides) jvmArgs += "-splash:app/resources/myImage.gif" // To make it work whatever is the working directory when invoking the app use: // jvmArgs += "-splash:${'$'}APPDIR/resources/splash.png" // ... } } </code>
compose.desktop {
    application {
        nativeDistributions {
            appResourcesRootDir = rootDir.resolve("myAssets")
            // ...
        }
        // The image path is relative to the app (Java) working directory
        // which is the app installation root directory (where the .exe file resides)
        jvmArgs += "-splash:app/resources/myImage.gif"
        // To make it work whatever is the working directory when invoking the app use:
        // jvmArgs += "-splash:${'$'}APPDIR/resources/splash.png"
        // ...
    }
}

It uses the myImage.gif image placed in <PROJECT_DIR>/myAssets/common/ directory.
See Adding files to packaged applications for more information.

The splash screen works when the app is launched with its installed exe or one of Compose Multiplatform run*Distributable tasks.
To also set the splash for application fat/uber jar (created with one of package*UberJar* tasks),
copy the splash image into classpath (like src/main/resources directory)
and add the code below in your build file to update all the Jar tasks:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>tasks.withType<org.gradle.jvm.tasks.Jar> {
manifest {
attributes["SplashScreen-Image"] = "myImage.gif"
}
}
</code>
<code>tasks.withType<org.gradle.jvm.tasks.Jar> { manifest { attributes["SplashScreen-Image"] = "myImage.gif" } } </code>
tasks.withType<org.gradle.jvm.tasks.Jar> {
    manifest {
        attributes["SplashScreen-Image"] = "myImage.gif"
    }
}

It seems that Windows does not respect the GIF speed and no-loop settings and
plays the animation at a low frame rate. See Gif Animated Files in C# have Lower framerates than they should.

See the related issue in Compose Multiplatform repository.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật