Understanding Activities

In Android, the building blocks of applications are activities, so before you start banging out bits and bytes, you need a firm understanding of what activities are and how they work. An activity is a single, focused thing a user can do or interact with in an application. For example, when an app presents a list of menu items the user can choose from, that's an activity. When an app displays photographs along with their captions, that's also an activity. An application may consist of just one activity, or like most applications in the Android system, it may contain several. Though activities may work together to appear to be one cohesive application, they are actually independent of each other. An activity in Android is an important part of an application's overall life cycle, and the way the activities are launched and put together is a fundamental part of the Android's application model.

In Android, each activity is implemented as an implementation of the Activity base class. Almost all activities interact with the user, so the Activity class takes care of creating the window for you in which you can place your user interface (UI). Activities are most often presented in full-screen mode, but in some instances, you can find activities floating in windows or embedded inside other activities — this is known as an activity group.

Working with stacks and states

Activities in the system are managed as an activity stack. As users work with a tablet, they move ...

Get Android™ Tablet Application Development For Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.