Understanding Activities

An activity is a single, focused action that a user can take. For example, an activity might present a list of menu items that a user can choose from, or it might display photographs along with captions. An application may consist of only one activity or (like most applications in the Android system) several. Though activities may work together to appear to be one cohesive application, they work independently from each other.

remember.eps 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 aspect of the Android application model. Every activity is implemented as an implementation of the Activity base class.

Almost all activities interact with the user, so the Activity class creates for you the window 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 an activity floating in a window or embedded inside another activity — known as an activity group.

Working with methods, stacks, and states

Two important methods that almost all activities implement are

check.png onCreate: Where the activity is initialized. Most importantly, it’s where you tell the activity which layout to use by using a layout ...

Get Android Application Development For Dummies, 2nd Edition 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.