The Very Basics of Android: Tasks, Activities, and the Backstack
Welcome to The Very Basics of Android! This series is aimed at folks just starting out on Android, and the goal is by the end of the series, you should be familiar enough with common Android topics to be able to go on to other intro materials.
To start, this first article will discuss the terminology we use when talking about the UI of the app: Tasks, Activities, and the Backstack.
Go onto your Android phone, and click on the small square button at the bottom of the screen. This screen represents all of the tasks running that you have opened! Here's what it looks like on my screen:
As you can see, I most recently opened Duolingo and second most recently opened the calculator app, so I have a Duolingo task as well as a calculator task. Each one of these tasks is just a stack of "webpages", called the backstack. Each one of these "webpages" we call an activity. Here's my artist's rendition of what this looks like:
When browsing a webpage, you are clicking on links in a webpage that opens up other webpages. Similarly, when browsing an app, you are clicking on "links" in an activity that opens up other activities. When you open an activity, it is added to the top of the backstack, like so:
When you press the back button on an activity, it pops the activity from the top of the backstack, like so:
Notice that, like a stack, all new activities are added to the top and removed from the top, hence the name backstack.
These are the basics of what makes up the UI of an app. In the next article, you'll learn:
- Activities are not the only things that can live in the backstack! Fragments can be added and popped as well.
- The app does not start activities, but rather, the Android OS code does!
Stay tuned for more!
Comments
Post a Comment