Lec 11.advanced Android Programming Topics
Lec 11.advanced Android Programming Topics
System apps
Java API Framework
Native C/C++ Libraries
Hardware Abstraction
Layer
Linux Kernel
Source: https://developer.android.com/guide/platform
Linux Kernel
The foundation of the Android platform
is the Linux kernel.
Source: https://developer.android.com/guide/platform
Native C/C++ Libraries
Many core Android system components
and services, such as ART and HAL, are
built from native code that require
native libraries written in C and C++.
The Android platform provides Java
framework APIs to expose the
functionality of some of these native
libraries to apps.
Source: https://developer.android.com/guide/platform
System Apps
Android comes with a set of core apps
for email, SMS messaging, calendars,
internet browsing, contacts, and more.
• Activities
• Services
• Broadcast receivers
• Content providers
Each type serves a distinct purpose and has a distinct lifecycle that defines
how the component is created and destroyed
Source: https://developer.android.com/guide/components/fundamentals
Four main application components:
Activities
Activity
An activity is the entry point for interacting with the user. It represents a
single screen with a user interface. For example, an email app might have
one activity that shows a list of new emails, another activity to compose an
email, and another activity for reading emails.
Source: https://developer.android.com/guide/components/fundamentals
Activity
An activity facilitates the following key interactions between system and app:
• Keeping track of what the user currently cares about (what is on screen) to ensure
that the system keeps running the process that is hosting the activity.
• Knowing that previously used processes contain things the user may return to
(stopped activities), and thus more highly prioritize keeping those processes around.
• Helping the app handle having its process killed so the user can return to activities
with their previous state restored.
• Providing a way for apps to implement user flows between each other, and for the
system to coordinate these flows. The most classic example is file sharing.
Source: https://developer.android.com/guide/components/fundamentals
Four main application components:
Services
Service
A service is a general-purpose entry point for keeping
an app running in the background for all kinds of
reasons. It is a component that runs in the background
to perform long-running operations or to perform work
for remote processes.
Source: https://developer.android.com/guide/components/fundamentals
Foreground services
A foreground service performs some operation that
is noticeable to the user. For example, an audio app
would use a foreground service to play an audio
track. Foreground services must display a
Notification. Foreground services continue running
even when the user isn't interacting with the app.
Source: https://developer.android.com/guide/components/services
Background services
A background service performs an operation that isn't directly noticed by
the user. For example, alarm clock service.
If the app targets API level 26 or higher, the system imposes restrictions on
running background services when the app itself isn't in the foreground. In
most situations, for example, you shouldn’t access location information from
the background.
Source: https://developer.android.com/guide/components/services
Bound services
Bound services run because some other app (or the system) has said that it
wants to make use of the service. This is basically the service providing an
API to another process.
Simple example is file downloading. The application can bind to some File
Downloader Service.
Source: https://developer.android.com/guide/components/services
Four main application components:
Broadcast receivers
Broadcast receivers
A broadcast receiver is a component that enables the system to deliver
events to the app outside of a regular user flow. The system can deliver
broadcasts even to apps that aren't currently running.
Source: https://developer.android.com/guide/components/broadcasts
Broadcast receivers
A popular example of Broadcast
receiver usage is handling Push
notifications.
Source: https://developer.android.com/guide/topics/providers/content-providers
Content provider
Content providers provide a nice way of abstraction for your data source. It
allows you to swap a data source without affecting any of the applications
that are using it.
Source: https://developer.android.com/guide/topics/providers/content-providers
Activating components
Application components
A unique aspect of the Android system design is that any app can start
another app’s component. For example, if you want the user to capture a
photo with the device camera, there's probably another app that does that and
your app can use it instead of developing an activity to capture a photo
yourself.
Unlike apps on most other systems, Android apps don't have a single
entry point (there's no main() function).
Source: https://developer.android.com/guide/components/fundamentals
Activating components
Activities, services, and broadcast receivers—are activated by an
asynchronous message called an “intent”. Intents bind individual
components to each other at runtime
Source: https://developer.android.com/guide/components/fundamentals
The manifest file
Before the Android system can start an app component,
the system must know that the component exists by
reading the app's manifest file, AndroidManifest.xml.
Your app must declare all its components in this file,
which must be at the root of the app project directory.
Source: https://developer.android.com/guide/components/fundamentals
Coursework Questions?
Recommended resources
https://developer.android.com/guide/platform
https://developer.android.com/guide/components/fundamentals
https://developer.android.com/guide/components/activities/intro-activities
https://developer.android.com/guide/components/services
https://developer.android.com/guide/components/broadcasts
https://developer.android.com/guide/topics/providers/content-providers