The Model of Applications in Android for Mobiles
Android form Google is an operating system for mobile phones that is based on Linux. The architecture of applications for Android introduces concepts that go beyond the classical models.
The data-view model
This is the model used by the library Swing of Java notably. The view is
the interface through which the user interacts with the software. Data are
stored separately and can be displayed in different views.
The view may also change the data according to the context, for example, change the text according to the user's language.
The Android model
Android extends this views/data model, it provides a new model that is suitable for equipment activated at all times. The structure of applications is defined as follows:
The views (Class android.view.View)
- The interface of a program for Android is a tree of views.
- The image at right shows four views inside a screen (an activity).
The file AndroidManifest.xml
It defines the components of the application and their relationships. It gives the permissions to application as to what it can do with users. It can also give permission to components of the application.
The components of the application:
- Activity (android.app.Activity class).
This is something that the user can do, translated into program. It corresponds to a screen, but can have multiple views.
- Intent (android.content.Intent class).
Describes an action which must be performed.
- Service (android.app.Service ).
Program that operates in background.
- Content Provider (android.content.ContentProvider class).
It encapsulates data and provides them commonly to several programs.
- Notification (android.app.NotificationManager and android.app.Notification
Class which informs the user about what is happening.
Besides components, there are also resources that can be XML files, image files as jpeg. They use the android.content.Resources interface and are stored in the res directory.
Components of the application
Each component is included in a list stored in the manifest file AndroidManifest.xml of each application.
HTC Hero with Android
An activity corresponds to a screen. If an application is composed of several
screens, it has an activity for each screen. Each activity is a class that
extends the base class Activity. It has a graphical user interface
made of views, and it responds to events. When you change screen, a new activity
It can return a value. For example, if an activity can choose something, text, image, it returns what is chosen.
The graphical interface
of an activity is described by a Layout:
- Full screen.
- Float: dialogue or alert.
- None. In this case it works in background and is invisible. It is maked visible by giving it a layout.
The intents are the goals of applications and are made effective by a new
screen. An intent is made up of an action and data that are URI.
Examples of actions: MAIN, VIEW, EDIT, PICK.
If one wants to see a card about a person, an intent is defined. The action is VIEW and the data is the URI which enables access to this card.
IntentFilters describes how the action should apply.
IntentReceiver is an object that responds to external events. It can operate in the application or it can start an application.
Example of intent, view a webpage: VIEW for action and for data http://www.scriptol.com.
A service is designed to operate independently of the screen, thus of activities. The best example is the music player that can works while moving from one screen to another.
Data stored by a computer program, in the form of files or SQLite databases
are private and may not be used by other applications.
But Content Provider may be used to share data among several applications. The interface ContentResolver is the interface that provides data to other objects.
The class android.app.Notification defines how an event must be notified to user: displaying an icon, changing state of a led, vibration, or others. While the class android.app.NotificationManager sends the message in the form so defined.
The Android application model offers concepts that go beyond an interface for mobile phones. It is designed for a set of applications that share data, each triggered by the other, running in background or in a view on the screen. It is an interface between the user and the operating system such as robotics, which could run on a laptop or desktop computer.
See also: Android and Nexus One.