Android forces a full restart after the application is killed

Hi My application works like this.

StartUpActivity starts first, which makes a lot of init elements. Then it starts TvbTabActivity (TabActivity), which has other actions as tabs (like BrowseActivity).

The problem I see is this: when the killer application is used to terminate my application on the TvbTabActivity / Browse tab and the application restarts again, the system refuses the normal flow (StartUpActivity is not created) but instead restores the last visible activity directly (TvbTabActivity).

How to make Android ALWAYS start StartUpActivity so that it initializes the application?

Obviously, I do not have this problem when my application crashes on its own, lol, due to an exception, and restarts again.

<application android:icon="@drawable/appicon" android:label="@string/app_name" android:name="com.xyz.QPApplication" android:debuggable="true"> <activity android:name=".activity.StartUpActivity" android:configChanges="locale|orientation" android:label="@string/app_name" android:screenOrientation="portrait"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".catalogue.BrowseActivity" android:configChanges="locale|orientation" android:label="@string/app_name" android:screenOrientation="portrait" android:launchMode="singleTop"> <intent-filter> <action android:name="com.xyz.android.intent.action.BROWSE" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activity.TvbTabActivity" android:configChanges="locale|orientation" android:screenOrientation="portrait" android:launchMode="singleTask"> </activity> 
+3
source share
3 answers

You can not. Android will try to restore the application where it stopped. The right way to handle this is to make sure that you understand the Activity life cycle and put the appropriate initialization in the right place.

0
source

There are several ways to solve your problem, it is best to check the Android lifecycle diagram http://code.google.com/android/images/activity_lifecycle.png and try to find out how the application works in this context.

Of course, if you really want you to be able to kill your own application by calling Activity.finish () when it enters onPause () or onStop (), but this is a pretty ugly solution.

0
source

There is nothing you can do about it - what happens to you is what the force API does and does.

Task killers abuse this API.

They can no longer use it in version 2.2 and later.

If you really want to avoid this, you can limit your application to only 2.2 or later. Or if the problem is that users complain about them, ask them to stop using task killers. Or if the problem is that you don’t like it when using the task killer, then do not use the task killer.

This is also the same behavior that occurs when a user clicks “Force stop” in the application management user interface. This is generally good, though, since the user must explicitly do this, instead of what these killer applications do more and more when they simply hit the material in the background without the direct involvement of the user.

0
source

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


All Articles