Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to always launch application from splash screen then last left activity

In my application I have several activities, If I'm leaving application in the middle of the application next time when application relaunches it starts with where I left I want my application to relaunch from splash screen and then it should move to the activity where i left, how can I do that

like image 212
blackHawk Avatar asked Jun 30 '17 14:06

blackHawk


People also ask

How do I create a splash screen activity?

The most straightforward way to create a simple splash screen was to create a dedicated theme overriding android:windowBackground with a drawable containing branding colors or a bitmap of a logo. The theme was set as an attribute of the launcher activity in AndroidManifest. xml.

What is splash screen in Android initial activity of an application?

Android Splash Screen is the first screen visible to the user when the application's launched. Splash screen is one of the most vital screens in the application since it's the user's first experience with the application.

How do I use splash screen API?

Set a theme for the splash screen to change its appearanceFor apps targeting Android 12 (API level 32) only: If the object is animatable and drawable through AnimationDrawable and AnimatedVectorDrawable , you also need to set windowSplashScreenAnimationDuration to play the animation while showing the starting window.


1 Answers

What exactly you mean be leaving the app?

Scenario 1: If user completely removed the app from the recent apps (it was terminated) next time user will open the app LAUNCHER (see AndroidManifest.xml) will be launched. So you should make your SplashActivity a LAUNCHER activity.

Scenario 2: In user minimised the app onPause and onStop and maybe onDestroy lifecycle methods on the current activity will be called. After user will restore the app from the recents (if the activity was destroyed then first onCreate method will be called) then onStart and onResume lifecycle methods will be called. See more on lifecycle methods in the docs.

Showing the splash screen each time user minimises and restores the app from recents not a particularly good idea, so I would recommended to stick with "Scenario 1" and show splash screen only once - when user launches the app. But if for some reason you want to show splash screen each time after user restores the app you can check this tutorial. It might be a bit tricky in Android as you can't show it just onResume or onStart as those methods will be called not only when you restore the app from the recents but also when you start this activity.

like image 183
Vadims Savjolovs Avatar answered Oct 21 '22 00:10

Vadims Savjolovs