I’m try to run SplashScreen api using jetpack compose on android lolipop5.1, the screen background is showing but the icon is not. i’m using splash api 1.0.1.
i’m using a viewmodel to make splash display longer.
class SplashScreenViewModel: ViewModel() {
private val _isLoading = MutableStateFlow(true)
val isLoading = _isLoading.asStateFlow()
init {
viewModelScope.launch {
delay(800)
_isLoading.value = false
}
}
}
Here is the manifest file
<?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:name=".MyApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@drawable/spotify"
android:label="@string/app_name"
android:roundIcon="@drawable/spotify"
android:supportsRtl="true"
android:theme="@style/Theme.MySplashScreen"
tools:targetApi="31">
<activity
android:name=".ui.activities.MainActivity"
android:exported="true"
android:theme="@style/Theme.MySplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Here is the theme.
<resources>
<style name="Theme.MySplashScreen" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/black</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/baseline_pause_24 </item>
<item name="postSplashScreenTheme">@style/Theme.AudioApp</item>
</style>
<style name="Theme.AudioApp" parent="android:Theme.Material.Light.NoActionBar" />
</resources>
here is MainActivity
class MainActivity : ComponentActivity() {
private val splashViewModel: SplashScreenViewModel by viewModels()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen().apply {
setKeepOnScreenCondition{
splashViewModel.isLoading.value
}
}
enableEdgeToEdge()
setContent {
AudioAppTheme {
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
HomeScreen(
0f,
{ },
false,
Audio(
id = 1,
audioName = "256",
audioUrl = "",
audioImage = R.drawable.image1,
artistName = "Selena",
duration = 250,
),
AudioRepositoryImpl().getTrackList(),
{ },
{ },
{}
)
}
}
}
}
}
}
I tried using different versions of splash api but it still not showing. I tired to change size of vector but it still not showing.