Android Training - Part 2
-
Upload
tbldevelopment -
Category
Technology
-
view
141 -
download
1
description
Transcript of Android Training - Part 2
![Page 1: Android Training - Part 2](https://reader033.fdocuments.us/reader033/viewer/2022061220/54bb81264a7959306a8b4638/html5/thumbnails/1.jpg)
Android
![Page 2: Android Training - Part 2](https://reader033.fdocuments.us/reader033/viewer/2022061220/54bb81264a7959306a8b4638/html5/thumbnails/2.jpg)
Android System Architecture
Source: Google
![Page 3: Android Training - Part 2](https://reader033.fdocuments.us/reader033/viewer/2022061220/54bb81264a7959306a8b4638/html5/thumbnails/3.jpg)
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
![Page 4: Android Training - Part 2](https://reader033.fdocuments.us/reader033/viewer/2022061220/54bb81264a7959306a8b4638/html5/thumbnails/4.jpg)
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.
![Page 5: Android Training - Part 2](https://reader033.fdocuments.us/reader033/viewer/2022061220/54bb81264a7959306a8b4638/html5/thumbnails/5.jpg)
Media Framework
• Android use OpenCore as core component of Media framework
• OpenCore supports MP3, AAC, AAC+, 3GPP, MPEG-4 and JPEG,
![Page 6: Android Training - Part 2](https://reader033.fdocuments.us/reader033/viewer/2022061220/54bb81264a7959306a8b4638/html5/thumbnails/6.jpg)
Media Framework
![Page 7: Android Training - Part 2](https://reader033.fdocuments.us/reader033/viewer/2022061220/54bb81264a7959306a8b4638/html5/thumbnails/7.jpg)
Media Framework
• Example: • MediaPlayer mp = new MediaPlayer(); • mp.setDataSource(PATH_TO_FILE); • mp.prepare(); • mp.start();
![Page 8: Android Training - Part 2](https://reader033.fdocuments.us/reader033/viewer/2022061220/54bb81264a7959306a8b4638/html5/thumbnails/8.jpg)
Media Framework
• OpenCore lib has a C/S Architecture.• MediaPlayer invoke JNI to manipulate client.• The client request to the server to control
hardwares.
![Page 9: Android Training - Part 2](https://reader033.fdocuments.us/reader033/viewer/2022061220/54bb81264a7959306a8b4638/html5/thumbnails/9.jpg)
Media Framework
![Page 10: Android Training - Part 2](https://reader033.fdocuments.us/reader033/viewer/2022061220/54bb81264a7959306a8b4638/html5/thumbnails/10.jpg)
Media Framework
![Page 11: Android Training - Part 2](https://reader033.fdocuments.us/reader033/viewer/2022061220/54bb81264a7959306a8b4638/html5/thumbnails/11.jpg)
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.
![Page 12: Android Training - Part 2](https://reader033.fdocuments.us/reader033/viewer/2022061220/54bb81264a7959306a8b4638/html5/thumbnails/12.jpg)
Life cycle of activity
Source: Hello Adroid
![Page 13: Android Training - Part 2](https://reader033.fdocuments.us/reader033/viewer/2022061220/54bb81264a7959306a8b4638/html5/thumbnails/13.jpg)
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
![Page 14: Android Training - Part 2](https://reader033.fdocuments.us/reader033/viewer/2022061220/54bb81264a7959306a8b4638/html5/thumbnails/14.jpg)
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.
![Page 15: Android Training - Part 2](https://reader033.fdocuments.us/reader033/viewer/2022061220/54bb81264a7959306a8b4638/html5/thumbnails/15.jpg)
Intent and Intent filters• Example• <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.EDIT" /> <action android:name="android.intent.action.PICK" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="vnd.android.cursor.dir/vnd.google.note" /> </intent-filter>
![Page 16: Android Training - Part 2](https://reader033.fdocuments.us/reader033/viewer/2022061220/54bb81264a7959306a8b4638/html5/thumbnails/16.jpg)
Activities and Tasks
• A task is a stack which contain several activities share the same affinity.
Source: http://blog.akquinet.de/2010/02/17/android-activities-the-predominance-of-the-ui-thread/
![Page 17: Android Training - Part 2](https://reader033.fdocuments.us/reader033/viewer/2022061220/54bb81264a7959306a8b4638/html5/thumbnails/17.jpg)
Activities and Tasks
• There are four different launch modes that can be assigned to an <activity> element's launchMode attribute:
• "standard" (the default mode) "singleTop" "singleTask" "singleInstance"
• First two share the same affinity with application, the others don’t.
![Page 18: Android Training - Part 2](https://reader033.fdocuments.us/reader033/viewer/2022061220/54bb81264a7959306a8b4638/html5/thumbnails/18.jpg)
Content manager
• Manage data• Client+server architecture. • Content Resolver provides API interface for
applications.• Content Providers is the server managing the
DB tables and database content with different application.
![Page 19: Android Training - Part 2](https://reader033.fdocuments.us/reader033/viewer/2022061220/54bb81264a7959306a8b4638/html5/thumbnails/19.jpg)
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
![Page 20: Android Training - Part 2](https://reader033.fdocuments.us/reader033/viewer/2022061220/54bb81264a7959306a8b4638/html5/thumbnails/20.jpg)
Service Lifecycle
![Page 21: Android Training - Part 2](https://reader033.fdocuments.us/reader033/viewer/2022061220/54bb81264a7959306a8b4638/html5/thumbnails/21.jpg)
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
![Page 22: Android Training - Part 2](https://reader033.fdocuments.us/reader033/viewer/2022061220/54bb81264a7959306a8b4638/html5/thumbnails/22.jpg)
References
• http://www.j2medev.com/android/ShowArticle.asp?ArticleID=5439
• http://docs.huihoo.com/google/io/2009/Mastering_the_Android_Media_Framework.pdf
• http://developer.android.com/