A typical Android application has the following components. Also given below are definitions provided by the Android Developer site:
- Activity — An activity presents a visual UI for one focused endeavor the user can undertake. For example, an activity might present a list of menu items users may choose from, or it might display photographs along with their captions. A text-messaging application might have one activity that shows a list of contacts to send messages to, a second activity to write the message to the chosen contact, and other activities to review old messages or change settings. Though they work together to form a cohesive UI, each activity is independent of the others.
- Content providers — A content provider makes a specific set of the application's data available to other applications. The data can be stored in the file system, in a SQLite database, or in any other logical manner.
- Service — A service doesn't have a visual UI, but runs in the background for an indefinite period of time. For example, a service might play background music as the user attends to other matters, or it might fetch data over the network or calculate something and provide the result to activities that need it.
- Broadcast receivers — A broadcast receiver is a component that does nothing but receive and react to broadcast announcements. Many broadcasts originate in system code — timezone-change announcements, low-battery announcements, language-preference changes, etc.
Some other terms worth knowing:
- Intent — Activities, services, and broadcast receivers are activated
by asynchronous messages called intents. An intent is an
Intentobject that holds the content of the message. For example, it might convey a request for an activity to present an image to the user or let the user edit some text.
- Intent filter — An Intent object can explicitly name a target component. If it does, Android finds that component (based on the declarations in the manifest file) and activates it. If a target is not explicitly named, however, Android must locate the best component to respond to the intent. It does so by comparing the Intent object to the intent filters of potential targets. A component's intent filters inform Android of the kinds of intents the component is able to handle.