Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android 12 splash screen setKeepVisibleCondition [closed]

I'm trying to implement a splash screen using android 12 SplashScreen compat library. I want to fetch some data from API each time my app starts. So the splash screen should wait until the API calls finish. I found this splashScreen.setKeepVisibleCondition() function in docs, but don't know how to implement KeepScreenOnCondition. How can I make my splash screen to wait? Any help would be appreciated.

like image 357
Sujith Manjavana Avatar asked Aug 31 '25 16:08

Sujith Manjavana


1 Answers

found the solution.

private var isLoading = true

override fun onCreate(savedInstanceState: Bundle?) {
    val splashScreen = installSplashScreen()
    splashScreen.setKeepVisibleCondition { isLoading }
}

private fun doApiCalls(){
    ...
    isLoading = false
}

like image 82
Sujith Manjavana Avatar answered Sep 03 '25 01:09

Sujith Manjavana