简体   繁体   中英

How to skip splashscreen when app is already running in background

I have a customer's requirement to provide the splash-screen with animation for an application, but skip the splash-screen when app is already running in background and user starts it again using the app's icon. Is there a way to do that?

Easy. Create static boolean variable in Application's (singleton) class. And set it to TRUE from Service. And check it inside Activity.onCreate().

I know a bit lengthy process but I am not sure if you would like it or not.

Step 1 :set up a global variable by extending application class (the life of global variable is not dependent on the activity but instead it is dependent on the application.

Step 2: use that global variable as a flag .Reset that global variable to 1(or whatever) if the activity has started.

Step 3: check the value of the global variable and then decide if you would like to display the splash screen or not

I created a tutorial for a View based splash screen. If you added some kind of parameter-logic to track if the application is already loaded could easily create the feature you are describing.

You can find the tutorial here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM