How to always launch the application from a pop-up screen, and then for the last time

In my application, I have several actions. If I leave the application in the middle of the application the next time the application restarts, it starts from where I left. I want my application to restart from the splash screen, and then it should go to where I left, how can I do it

+5
source share
1 answer

What exactly do you want to leave from the application?

Scenario 1. If the user completely uninstalled the application from the latest applications (it was interrupted), the next time the user opens the LAUNCHER application (see AndroidManifest.xml ). Therefore, you should make your activity SplashActivity a LAUNCHER .

Scenario 2: the user minimizes the onPause and onStop and possibly onDestroy methods for the current activity. After the user restores the application from retentates (if the action was destroyed, the first onCreate method will be called), then the onStart and onResume life cycle methods will be called. For more information on lifecycle methods, see the docs .

Showing the screen saver every time the user minimizes and restores the application from retentates is not a good idea, so I would recommend sticking to β€œScenario 1” and showing the screen saver only once β€” when the user starts the application. But if for some reason you want to show the screen saver every time after the user restores the application, you can check out this tutorial . This can be a bit complicated in Android, since you cannot show it simply onResume or onStart , since these methods will be called not only when restoring the application from retentates, but also when starting this operation.

+2
source

Source: https://habr.com/ru/post/1269371/


All Articles