8/12/2019 Android Middleware
1/22
Android Middleware
Bo Pang
8/12/2019 Android Middleware
2/22
Android System Architecture
Source: Google
8/12/2019 Android Middleware
3/22
overview
Linux Kernel: memory management, process
management, networking, and other
operating system services.
Native Libraries: written in C or C++, including:
Surface Manager, 2D and 3D graphics, Media
codes, SQL database, Browser engine, etc.
only to be called by higher level programs
8/12/2019 Android Middleware
4/22
overview
Android Runtime: including the Dalvik virtual
machine and the core Java libraries. (not
J2SE/J2ME)
Application Framework: Activity manager,
Content providers, Resource manager,
Notification manager
Applications and Widgets: the real programs
display information and interact with users.
8/12/2019 Android Middleware
5/22
Media Framework
Android use OpenCore as core component of
Media framework
OpenCore supports MP3, AAC, AAC+, 3GPP,
MPEG-4 and JPEG,
8/12/2019 Android Middleware
6/22
Media Framework
8/12/2019 Android Middleware
7/22
Media Framework
Example:
MediaPlayer mp = new MediaPlayer();
mp.setDataSource(PATH_TO_FILE); mp.prepare();
mp.start();
8/12/2019 Android Middleware
8/22
Media Framework
OpenCore lib has a C/S Architecture.
MediaPlayer invoke JNI to manipulate client.
The client request to the server to controlhardwares.
8/12/2019 Android Middleware
9/22
Media Framework
8/12/2019 Android Middleware
10/22
Media Framework
8/12/2019 Android Middleware
11/22
Activity Manager
each user interface screen is represented by
an Activity class.
Each activity has its own life cycle.
Activity uses Intent object to jump between
them.
8/12/2019 Android Middleware
12/22
Life cycle of activity
Source: Hello
Adroid
8/12/2019 Android Middleware
13/22
Intent and Intent filters
Intent activates activities, services, and
broadcast receivers.
Intent can be used in explicit way or implicit
way.
The implicit way depends on parameters:
Action, Data(url and MIME type) , Category
8/12/2019 Android Middleware
14/22
Intent and Intent filters
To receive other components' request,
components need to register filters at
activities framework.
When launch a intent object, framework will
match and find the qualified components and
leave them for users to choose which to run.
8/12/2019 Android Middleware
15/22
Intent and Intent filters
Example
8/12/2019 Android Middleware
16/22
Activities and Tasks
A task is a stack which contain several
activities share the same affinity.
Source:
http://blog.akquinet.de/20
10/02/17/android-activities-the-
predominance-of-the-ui-
thread/
8/12/2019 Android Middleware
17/22
Activities and Tasks
There are four different launch modes thatcan be assigned to an element'slaunchModeattribute:
"standard" (the default mode)"singleTop""singleTask""singleInstance"
First two share the same affinity withapplication, the others dont.
http://developer.android.com/guide/topics/manifest/activity-element.htmlhttp://developer.android.com/guide/topics/manifest/activity-element.html8/12/2019 Android Middleware
18/22
Content manager
Manage data
Client+server architecture.
Content Resolver provides API interface forapplications.
Content Providers is the server managing the
DB tables and database content with different
application.
8/12/2019 Android Middleware
19/22
Content manager
URI identifies the data or the table
A: Standard prefix indicating that the data is
controlled by a content provider.
B: The authority part of the URI; it identifies the
content provider.
C: The path that the content provider uses to
determine what kind of data is being requested.
D: The ID of the specific record being requested.
Source: Google
8/12/2019 Android Middleware
20/22
Service Lifecycle
8/12/2019 Android Middleware
21/22
Security and permissions
security between applications and the system
is enforced at the process level through
standard Linux facilities
Application can't disrupt other applications,
except by explicitly declaring the permissions
it
Each Android package is given its own unique
Linux user ID
8/12/2019 Android Middleware
22/22
References
http://www.j2medev.com/android/ShowArticl
e.asp?ArticleID=5439
http://docs.huihoo.com/google/io/2009/Mast
ering_the_Android_Media_Framework.pdf
http://developer.android.com/
http://www.j2medev.com/android/ShowArticle.asp?ArticleID=5439http://www.j2medev.com/android/ShowArticle.asp?ArticleID=5439http://docs.huihoo.com/google/io/2009/Mastering_the_Android_Media_Framework.pdfhttp://docs.huihoo.com/google/io/2009/Mastering_the_Android_Media_Framework.pdfhttp://developer.android.com/http://developer.android.com/http://docs.huihoo.com/google/io/2009/Mastering_the_Android_Media_Framework.pdfhttp://docs.huihoo.com/google/io/2009/Mastering_the_Android_Media_Framework.pdfhttp://www.j2medev.com/android/ShowArticle.asp?ArticleID=5439http://www.j2medev.com/android/ShowArticle.asp?ArticleID=5439