Professional Documents
Culture Documents
11.intro Andr
11.intro Andr
11.intro Andr
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks
Content
2 Android Architecture
4 Android Emulator
6 Lifecycle callbacks
Android Architecture
Continue....
Continue....
The application framework houses the API interface. In this layer, the
activity manager governs the application life cycle. The content providers
enable applications to either access data from other applications or to share
their own data. The resource manager provides access to non-code
resources (such as graphics), while the notication manager enables
applications to display custom alerts. On top of the application framework
are the built-in, as well as the user applications, respectively. It has to be
pointed out that a user application can replace a built-in application, and
that each Android application runs in its own process space, within its own
DVM instance. Most of these major Android components are further
discussed (in more detail) in the next few sections of this report.
content...
Application
Application framework
Application runtime
Platform libraries
Linux Kernel
Security: The Linux kernel handles the security between the application
and the system. Memory Management: It eciently handles the memory
management thereby providing the freedom to develop our apps. Process
Management: It manages the process well, allocates resources to processes
whenever they need them. Network Stack: It eectively handles the
network communication. Driver Model: It ensures that the application
works properly on the device and hardware manufacturers responsible for
building their drivers into the Linux build.
An android component is simply a piece of code that has a well dened life
cycle e.g. Activity, Receiver, Service etc.
The core building blocks or fundamental components of android are
activities, views, intents, services, content providers, fragments and
AndroidManifest.xml.
Activity:
Being similar to a Frame in AWT, an activity as a class represents a
single screen. It is a core building block, i.e., the fundamental
component of android.
View: The UI element including button, label, text eld, etc, and
anything that one can see is a view.
Continue....
Intent: Along with invoking the components, the Intent is used for many
purposes including:
Start the service
Launch an activity
Display a web page
Display a list of contacts
Broadcast a message
Dial a phone call etc.
Continue....
Service: Being a background process the service can run for a long
time.
The local and remote are the two types of services. Within the
application, the local service is accessed. While from other
applications running on the same device the remote service can be
accessed remotely.
Content Provider: To share the data between the applications, the
Content Providers are used.
Fragment: Being a part of an activity, one or more fragments can be
displayed on the screen at the same time by the activity.
Continue....
Android Emulator
Continue....
Continue....
Lifecycle callbacks
onCreate()
You must implement this callback, which res when the system rst creates
the activity. On activity creation, the activity enters the Created state. In
the onCreate() method, you perform basic application startup logic that
should happen only once for the entire life of the activity. For example,
your implementation of onCreate() might bind data to lists, associate the
activity with a ViewModel, and instantiate some class-scope variables. This
method receives the parameter savedInstanceState, which is a Bundle
object containing the activity's previously saved state. If the activity has
never existed before, the value of the Bundle object is null.
onStart()
When the activity enters the Started state, the system invokes this
callback. The onStart() call makes the activity visible to the user, as the
app prepares for the activity to enter the foreground and become
interactive. For example, this method is where the app initializes the code
that maintains the UI.
onResume()
When the activity enters the Resumed state, it comes to the foreground,
and then the system invokes the onResume() callback. This is the state in
which the app interacts with the user. The app stays in this state until
something happens to take focus away from the app. Such an event might
be, for instance, receiving a phone call, the user's navigating to another
activity, or the device screen's turning o.
onPause()
The system calls this method as the rst indication that the user is leaving
your activity (though it does not always mean the activity is being
destroyed); it indicates that the activity is no longer in the foreground
(though it may still be visible if the user is in multi-window mode). Use the
onPause() method to pause or adjust operations that should not continue
(or should continue in moderation) while the Activity is in the Paused
state, and that you expect to resume shortly. There are several reasons why
an activity may enter this state. For example:
Continue....
onStop()
When your activity is no longer visible to the user, it has entered the
Stopped state, and the system invokes the onStop() callback. This may
occur, for example, when a newly launched activity covers the entire
screen. The system may also call onStop() when the activity has nished
running, and is about to be terminated.
onDestroy()