I have followed this article Splash screen for below all API levels with icon without any activity. support splash screen for both devices below android 12 and above.
The splash screen works fine in both versions, but after splash screen finish in android 12 the action bar appears although i’m using edgetoEdge(), but it works just fine in a android 5.1.
Here how it appears on device running android 12.
Device running android 5.1.
this is theme.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.SpotifyApp" parent="android:Theme.Material.Light.NoActionBar" >
<item name="android:statusBarColor">@color/black</item>
<item name="android:windowBackground">@drawable/splash_background</item>
</style>
</resources>
this theme.xml for V31
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Splash" parent="android:Theme.Material.Light.NoActionBar" />
<style name="Theme.SpotifyApp" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/black</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/spotify</item>
<item name="windowSplashScreenAnimationDuration">3000</item>
<item name="postSplashScreenTheme">@style/Theme.Splash</item>
</style>
</resources>
Manifest
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@drawable/spotify_icon_small"
android:label="@string/app_name"
android:roundIcon="@drawable/spotify_icon_small"
android:supportsRtl="true"
android:theme="@style/Theme.SpotifyApp"
tools:targetApi="31">
<activity
android:name="com.example.spotify.activities.MainActivity"
android:exported="true"
android:theme="@style/Theme.SpotifyApp">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Theme.kt
@Composable
fun SpotifyTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = false,
content: @Composable () -> Unit
) {
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}
darkTheme -> DarkColorScheme
else -> LightColorScheme
}
MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
content = content
)
}
MainActivity
class MainActivity : ComponentActivity() {
@OptIn(ExperimentalMaterial3Api::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
installSplashScreen()
setContent {
SpotifyTheme {
CompositionLocalProvider(LocalRippleConfiguration provides null) {
Surface(modifier = Modifier
.fillMaxSize()
.background(MaterialTheme.colorScheme.background)){
MyAppNavigation()
}
}
}
}
}
}
tried different solutions i found but still unable to solve it. Note that the splash screen in both device shows correctly without action bar