开发者

Android: 'Splash screen' only once

开发者 https://www.devze.com 2023-01-14 09:38 出处:网络
I have a Android application that requires a splash screen. I have a simple activity which shows the splash screen and after a number of seconds, it starts the \'main\' activity. Now, when a user pres

I have a Android application that requires a splash screen. I have a simple activity which shows the splash screen and after a number of seconds, it starts the 'main' activity. Now, when a user presses t开发者_StackOverflow中文版he back button from that activity, the splash screen shows again. How can I prevent this? I tried keeping a boolean shownSplash and this partially works, but when the app is running and the user wants to open it from the app-launcher, the app exits (since splash calls finish() when splashShown is true). Any ideas?

Thanks, Erik


Set android:noHistory="true" to the activity entry at the AndroidManifest.xml. That will prevent the activity from being saved on the stack.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号