Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between attributes clearTaskOnLaunch versus finishOnTaskLaunch?

Tags:

android

According to the docs:

android:clearTaskOnLaunch

Whether or not all activities will be removed from the task, except for the root activity, whenever it is re-launched from the home screen — "true" if the task is always stripped down to its root activity, and "false" if not. The default value is "false". This attribute is meaningful only for activities that start a new task (the root activity); it's ignored for all other activities in the task.

When the value is "true", every time users start the task again, they are brought to its root activity regardless of what they were last doing in the task and regardless of whether they used the Back or Home button to leave it. When the value is "false", the task may be cleared of activities in some situations (see the alwaysRetainTaskState attribute), but not always.

android:finishOnTaskLaunch

Whether or not an existing instance of the activity should be shut down (finished) whenever the user again launches its task (chooses the task on the home screen) — "true" if it should be shut down, and "false" if not. The default value is "false".

I see that the verbiage between these two attributes is distinct, yet I cannot realize the practical differences amongst them. Any help here?


1 Answers

clearTaskOnLaunch

If this attribute is set to "true" in the root activity of a task, the stack is cleared down to the root activity whenever the user leaves the task and returns to it.

finishOnTaskLaunch

This attribute is like clearTaskOnLaunch, but it operates on a single activity, not an entire task. It can also cause any activity to go away, including the root activity. When it's set to "true", the activity remains part of the task only for the current session. If the user leaves and then returns to the task, it is no longer present.

refer this blog

like image 79
Piyush Kukadiya Avatar answered Dec 24 '25 03:12

Piyush Kukadiya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!