Android:“启动画面”只有一次

发布于 2024-09-17 08:37:00 字数 242 浏览 2 评论 0原文

我有一个 Android 应用程序需要启动画面。我有一个简单的活动,它显示启动屏幕,几秒钟后,它启动“主要”活动。现在,当用户在该活动中按下后退按钮时,启动画面将再次显示。我怎样才能防止这种情况发生?我尝试保留一个布尔值 shownSplash ,这部分有效,但是当应用程序正在运行并且用户想要从应用程序启动器打开它时,应用程序退出(因为当 flashShown 为 true 时,splash 调用 finish() )。有什么想法吗?

谢谢, 埃里克

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 the 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

滥情哥ㄟ 2024-09-24 08:37:01

android:noHistory="true" 设置为 AndroidManifest.xml 中的活动条目。这将阻止活动保存在堆栈上。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文