ClearTaskOnLaunch HowTo?

Reading the documentation for Android , and some of the answers here will leave it ambiguous, how clearTaskOnLaunch should work. Specifically

1) How is root activity determined? Is it easy with DEFAULT, LAUNCHER or MAIN filters?

2) Starting from the “home screen” in the documentation means the OS initial screen or a list of applications, right? That is, from not inside the application.

3) Does clearTaskOnLaunch clear the activity stack whenever this activity starts from the main screen or only when this activity process starts from the main screen? Because the documents point to the former, but the messages here point to the latter. I think it depends on what the definition of "launch" is.

EDIT: 4) Does clearing the activity stack literally erase it or loop through onCreate () and finish ()?

I manipulated clearTaskOnLaunch in all possible ways without any effects. I put it in my activity in the manifest, and then put it in EVERY activity to be sure, restarted my application after the process was completely destroyed, etc. My activity stack is simply not cleared.

Can anyone suggest a complete overview of how to implement clearTaskOnLaunch?

+6
android android-activity android-manifest
source share
1 answer

Here's the full answer from the Android engineer for the groups: http://groups.google.com/group/android-developers/browse_thread/thread/da024bcaf4e1960f

Reading the documentation on Android and some of the answers here (and on StackOverflow) left it ambiguous, how clearTaskOnLaunch should behave, in particular:

1) "Clearing" the action stack means literally erasing it or with a cycle of actions through onCreate () and finish ()?

All actions in the cleaned stack will go through the life cycle, as if they were called finish (). Root activity will usually persist as is.

2) How is root activity identified? Is it just the one that is DEFAULT, STARTUP, or MAIN filters?

This is basically the first action on the stack. The goal is the Destination used to launch the stack.

3) Running from the “home screen” in the documentation means that the OS of the home screen or list of applications, right? That is, out of no expression.

It doesn't really matter — it's just the one who sets Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED. The standard launcher is when you start the application from the icon. You can install it yourself if you want.

4) Does clearTaskOnLaunch clear the activity stack whenever an activity starts from the main screen or an activity starts from the main screen? Since the documents point to the former, but the messages here indicate the latter. I think it depends on what the definition of "launch" is?

Whenever it starts from the main screen. The fact that processes are killed and restarted must be invisible to the user.

I manipulated clearTaskOnLaunch in all possible ways, absolutely no effect. I put it in my root activity in the manifest, and then put it in EVERY activity, to be sure, my application was restarted after the process was completely destroyed, etc. My stack activity just doesn't get cleared.

The settings use this as an example - if you go into the settings, dig out a little, press the "home" button, and then run the settings again, you will be taken to home activity, not wherever you are. It just sets a flag in the main action of the application.

+5
source share

All Articles