How do I show the splash screen only when an activity starts instead of when it resumes?… here is a solution to the problem.
How do I show the splash screen only when an activity starts instead of when it resumes?
I want the splash screen to only show up when the app is completely destroyed, not when it’s running in the background and recovering
Solution
Android’s Live-Circle
When creating Acrivity:
- onCreate
- Start
- onResume
When your activity becomes non-active:
- Pause
- Stop
When it activates again:
- Reboot
- Start
- onResume
When it is destroyed:
- Pause
- Stop
- onDestroy
EDIT: What I’ll do is, I’ll define a global boolean value for your Main-activity, such as “showSpash”, and initialize it to “true”. Then, when the “onCreate” method is first called, set it to “false”.
Then, whenever the “onCreate” method is called, you check whether the boolean value is “false”. If it is, the splash is not displayed if it is not.