开发者

Android: Resetting the splash screen

开发者 https://www.devze.com 2023-03-26 21:13 出处:网络
开发者_JAVA百科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.

开发者_JAVA百科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.

Someone has said: "Set clearTaskOnLaunch via the Android Manifest of your project to true. This will clear the task/stack history whenever the activity is launched." -- But I don't know where to put it in the Anndoird Manifest.. and I'm not even sure this is the solution to my problem as I effectively want the whole app to be started again when then icon is clicked -- not resumed on the last page.

Help?!

THanks


You can set android:clearTaskOnLaunch="true" in the Android Manifest file where your 'Splash Activity' is defined with the <activity/> tag.

There is a clear explanation of the behaviour here.


Do you want the splash screen to show when pressing back from the login activity? Because any user would hate that. Do your users a favor and call finish() after starting the login activity from the splash screen. However, if you actually care for your users a little bit you would remove the splash screen altogether (unless you have some data to load, or something that actually takes two seconds to complete, and can't be postponed).

Now, on to your main problem. Yes, the Android OS does keep your activity stack in memory for a while, but only if you use the HOME button to effectively minimize the application. If you press the back button, the activity is terminated. When there are no more activities, the process is terminated (using the back button). It's not recommended to override this behavior, so I won't post any pointers on that (although others already have).


Hitting 'back' doesn't terminate your application. Hence it goes back to the last opened screen. If you terminate your application, the splash will re-appear (as you stated).

This is an interesting read for you.

0

精彩评论

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