In Android, what's the difference between "backstack" and "task"?

207 views Asked by At

I can't understand why there are two terms. It seems redundant that a all of the activities exist in a task, and all activities exist in a backstack, and the task "uses" the backstack to organize the activities. Did someone drop Occam's razor down the drain, or are these actually two distinct entities that different parts of the operating system have to deal with separately?

I've searched around google and some forums and haven't found a satisfactory answer. I know it seems frivolous, but this is a real question that matters to me; I have a tiny informational digestive tract that can't take in anything new until the present stuff is fully metabolized. I'm new to code, and it's hurting my brain. Please assist.

2

There are 2 answers

1
Mikhail Guliaev On
  1. Task is a set of activities activities that the user interacts with when performing a certain action or workflow.

  2. Backstack is a stack of activities that the user has navigated through within a particular task. When the user moves from one activity to another, the previous activity is pushed onto the back stack. When the user presses the back button, the previous activity is popped off the stack and becomes the current activity.

For example, you opens Twitter app and Android creates a task for it. Then you see feed and click on some tweet. Activity with some tweet opens. So, in this task there is a backstac with 2 activities in it.

So, to answer your question, the task and the back stack are two separate concepts, but they are closely related. The task represents the overall context in which the user is interacting with a set of activities, while the back stack represents the user's history of navigation within that context.

4
Tenfour04 On

Conceptually, the task contains a back stack of Activities, but it would be confusing to talk about back stacks of tasks that are not currently on screen.

Task is the technical term actually used in the code. You don't need to precisely define back stack, so these terms are mostly interchangeable.