Android:闪屏问题
在我的 Android 应用程序上,我设置了启动屏幕。打开应用程序时会打开初始屏幕,并持续两秒钟,然后重定向到登录屏幕。
我遇到的问题是启动屏幕显示一次,然后重定向到登录屏幕。但是,当我再次单击该应用程序时,它会直接进入登录屏幕,忽略启动屏幕。这是有原因的吗?它会在您的最后一个屏幕上自动打开吗?因为如果我在登录屏幕上打开后退按钮,它会返回到初始屏幕,但 2 秒后不会重定向到登录屏幕。
On my Android App, I have set up a splash screen. The splash screen opens when the app is opened and lasts for two seconds before it redirects to a login screen.
The issue I am having is that the splash screen displays once, and then re-directs to the login screen. BUT when I click on the app again it goes straight to the login screen ignoring the splash screen. Is there a reason for this? Does it automatically open on your last screen? Because then if I hit the back button when it opens on the login screen it DOES go back to the splash screen but then doesn't redirect to the login screen after 2 seconds.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,这是正常行为。当您在第二次启动后点击后退按钮时,您将结束该应用程序,因此您的启动屏幕将在下次启动时显示。您需要向登录活动的恢复方法添加一个意图,以启动启动画面。这是简历示例。 使用 onResume、onStart 和 onRestart 的 Android 示例< /a>
Yes this is normal behavior. When you hit the back button after the second launch you are ending the app, thus your splash screen shows on the next launch. You will need to add an intent to your login activity's on resume method to launch your splash screen. Here is a on resume example. Android example which uses onResume, onStart and onRestart
通过项目的 Android Manifest 将clearTaskOnLaunch 设置为 true。每当启动活动时,这都会清除任务/堆栈历史记录。
Set clearTaskOnLaunch via the Android Manifest of your project to true. This will clear the task/stack history whenever the activity is launched.