[英]App stuck on the Splash screen in Android 12 (API Level 31)
應用程序卡在啟動畫面上。 不知道為什么? 我所做的一切都與文檔相同。 請看我的代碼,請告訴。
Android Manifest.xml 文件代碼:
<activity
android:name=".ui.startup.StartupActivity"
android:exported="true"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
樣式.xml 代碼
<style name="SplashTheme" parent="Theme.SplashScreen">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/splash</item>
</style>
app.gradle 依賴代碼:
implementation 'androidx.core:core-splashscreen:1.0.0-alpha01'
啟動活動代碼:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen()
}
override fun onStart() {
super.onStart()
proceedNavigation()
}
我尚未在 Android 12 中實現啟動畫面,但根據您的代碼和某些文檔,您需要添加 setConetView 並且您必須在它之前調用 installSplashScreen()。
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen()
setContenView(layout)
}
override fun onStart() {
super.onStart()
proceedNavigation()
}
根據本文檔,您必須在主活動或啟動器活動中調用 installSplashScreen 函數。 您必須在 setContentView 之前調用它。
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val splashScreen = installSplashScreen()
setContentView(R.layout.activity_main)
您還應該考慮為屬性 postSplashScreenTheme 指定活動主題,以便您可以為啟動畫面和應用程序設置單獨的主題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.