Difference between finish() and finishAndRemoveTask()

6.1k views Asked by At

I have little confusion between finish() method and finishAndRemoveTask() method. If any one have idea about it than please explain difference between them.

3

There are 3 answers

1
Strider On

finish() closes the current activity and optionally propagates the result of this activity to whoever launched it.

finishAndRemoveTask() closes the activity and removes the task as a part of finishing the root activity of the task. The task is also removed from recents.

0
jjz On

First you need to be familiar what is a "Task" and "Back Stack"

A task is a collection of activities that users interact with when performing a certain job. The activities are arranged in a stack (the back stack), in the order in which each activity is opened. For more details, you can refer to: http://developer.android.com/guide/components/tasks-and-back-stack.html

finish() will close the active Activity finishAndRemoveTask() will close the active Activity and clear any pending tasks.

0
0xAliHn On

finish() - close your activity. Call this when your activity is done and should be closed.

finishAndRemoveTask() - Finishes all activities in this task and removes it from the recent tasks list.