Java – How do I show the splash screen only when an activity starts instead of when it resumes?

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:

  1. onCreate
  2. Start
  3. onResume

When your activity becomes non-active:

  1. Pause
  2. Stop

When it activates again:

  1. Reboot
  2. Start
  3. onResume

When it is destroyed:

  1. Pause
  2. Stop
  3. 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.

Related Problems and Solutions