Android Application Overview

An Android application consists of various functionalities. Some examples are editing a note, playing a music file, ringing an alarm, or opening a phone contact. These functionalities can be classified into four different Android components, shown in Table 2.1, each of which is specified by a Java base class.

Table 2.1 The Four Possible Components of an Android Application


Focused thing a user can do Background process Receive messages Store and retrieve data

Java Base Class

Activity Service

BroadcastReceiver ContentProvider


Edit a note, play a game Play music, update weather icon Trigger alarm upon event Open a phone contact

Every application is made up of one or more of these components.They are instantiated by the Android operating system (OS) as needed. Other applications are allowed to use them, too, within the specified permissions.

As multiple functionalities play out in the OS (some not even related to the intended application, such as an incoming phone call), each component goes through a lifecycle of getting created, focused, defocused, and destroyed. The default behavior can be overridden for a graceful operation, such as saving variables or restoring user interface (UI) elements.

With the exception of ContentProvider, each component is activated by an asynchronous message called an Intent.The Intent can contain a Bundle of supporting information describing the component.This provides a method of passing information between components.

The rest of this chapter demonstrates the previous concepts using the most common component: the Activity. Because activities almost always specify an interaction with a user, a window is automatically created with each activity. Therefore, a short introduction to the UI is also included. Of the other components, Service and BroadcastReceiver are covered in Chapter 3,"Threads, Services, Receivers, and Alerts," and ContentProvider is covered in Chapter 9, "Data Storage Methods."

Character Building Thought Power

Character Building Thought Power

Character-Building Thought Power by Ralph Waldo Trine. Ralph draws a distinct line between bad and good habits. In this book, every effort is made by the writer to explain what comprises good habits and why every one needs it early in life. It draws the conclusion that habits nurtured in early life concretize into impulses in future for the good or bad of the subject.

Get My Free Ebook

Post a comment