How to make pop-up screen not load if application is already in memory

I have problems with spam screens. When I launch the application, the splash screen activity starts in a few seconds. After the launch of the main event.

And if I click the Home button in the main action, and then restart the application from the list of applications, the burst activity starts again, although the application is already in the back. But I expect that the main activity will be restored from memory.

And if I press the "Back" button after the android returns me to the previous copy of the main action.

What do I need to do so that the screen saver appears only once? And how to make my application resume from the last screen that I saw before pressing the home button?

<activity android:name=".ui.SplashActivity" android:noHistory="true" android:screenOrientation="portrait" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:name=".ui.MainActivity"/> 
0
source share
1 answer

This is a design issue. Your launch activity should not be your screensaver activity. Instead, open your burst activity in your main onCreate method. Thus, if it is open, onCreate is called and the splash screen is displayed. Otherwise, if the application simply resumed, which calls onResume, there would be no call to open the screensaver activity.

Then you can change your manifest to this:

 <activity android:name=".ui.MainActivity" android:noHistory="true" android:screenOrientation="portrait" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:name=".ui.SplashActivity"/> 
+5
source

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


All Articles