We use cookies to give you a better experience. Carry on browsing if you're happy with this, or read our cookies policy for more information.

Skip main navigation

A quick refresher of application components under Android

A quick refresher of application components under Android
© University of Southampton 2017
The Android programming model both simplifies app development, and facilitates app cooperation, via a component based architecture.
Each Android app consists of a collection of components that work both together, and potentially with components of other apps, in order to provide the app’s functionality. The developer does not write a main method for their app, instead they write components that may be invoked by other parts of their app, or by other apps, including those that come as part of Android itself.
This is great from a user experience point of view. Collectively the components of the different apps installed on a device cooperate and provide a rich user experience, where apps are able to access data stored by other apps, or get other apps to perform tasks on their behalf.
However, from a security point of view this cooperation between apps is open to abuse, and app developers must think carefully about how they structure their apps, and how the services they provide may be abused.

The different component types

Components come in four types:
  1. Activities: these are components that provide a user interface screen and correspond to activities that the user might perform, e.g. dial a phone number, take a photograph, or compose an email.
  2. Services: these are components that perform potentially long-running tasks that operate in the background without a user interface, e.g. downloading a file, playing music, or synchronising email with a server.
  3. Broadcast Receivers: these are components that listen for messages broadcast by other components (possibly in other apps) and then perform an action, e.g. when a phone call is received this is broadcast to other apps so music players for example can pause playback.
  4. Content Providers: these are components that provide controlled access to their app’s data. Content Providers are intended for when an app wants to share its data with other apps, e.g. a contacts app may want to share access to its database with the phone app or an email app.
Android provides mechanisms by which a component can communicate with another component, or ask another component to perform an action on its behalf. The Principle of Least Privilege says that we should secure these interactions.
Every Android application must have an AndroidManifest.xml file which (among other things) lists the app’s components so that Android can run them.
Note for Nerds: unlike the other types of components, Broadcast Receivers can also be registered programmatically. This is done using registerReceiver(). A typical use for doing this would be if an app is only interested in a certain type of message when it is in a particular state. A Broadcast Receiver registered with registerReceiver() can be unregistered with unregisterReceiver().
© University of Southampton 2017
This article is from the free online

Secure Android App Development

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education