네, Android 12 부터는 Splash screen이 기본으로 추가되어 있기 때문에 무조건 추가하시면 두개가 뜨게됩니다. 아래 링크를 읽어보시면 자세한 내용을 확인할 수 있습니다.
https://developer.android.com/guide/topics/ui/splash-screen
다른 방법도 있겠지만 API레벨에 상관없이 splash screen을 구현하는 손쉬운 방법은 API31부터 추가된 splash screen API를 사용하는 것 같네요.
먼저 아래 dependency를 build.gradle에 추가하세요. compileSdk는 31롤 설정하시는거 잊지마시구요.
implementation 'androidx.core:core-splashscreen:1.0.0-rc01'
|
res/values/xml에 아래와 같이 Splash screen용 theme을 추가하세요.
< style name = "Theme.App.Starting" parent = "Theme.SplashScreen" >
< item name = "windowSplashScreenBackground" >@color/teal_700</ item >
< item name = "windowSplashScreenAnimatedIcon" >@drawable/splash_image</ item >
< item name = "windowSplashScreenAnimationDuration" >3000</ item >
< item name = "postSplashScreenTheme" >@style/Theme.App</ item >
</ style >
|
각 항목에 대한 자세한 설명은 아래 링크를 보시면 나오니 참고하세요. 저도 그래도 따라한거예요.
https://developer.android.com/guide/topics/ui/splash-screen/migrate
AndroidMainfest.xml에 가서 시작 액비티티의 theme에 위에서 정의한 theme을 설정하세요.
<activity
android:theme= "@style/Theme.App.Starting"
android:name= ".MainActivity"
android:exported= "true" >
<intent-filter>
<action android:name= "android.intent.action.MAIN" />
<category android:name= "android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
|
마지막으로 MainActivity에 가서 splash screen 초기화를 해줍니다. super.onCreate 앞에 installSplashScreen을 호출하세요.
override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
super .onCreate(savedInstanceState)
}
|
이게 끝입니다. API 31전후로 잘 동작하는 걸 확인했습니다.