Hello, third edition of Android (II)

Source: Internet
Author: User



Chapter 2

Framework

 


2.1

Frame chart

 

Linux

Kernel

Android

Core system services depend on

For Linux 2.6

Kernel, such as security, memory management, process management,

Network protocol stack and driver model.

Linux

The kernel also serves as the abstraction layer between the hardware and the software stack.

Native Library (

Native Library

)

In

Linux

On the kernel is

Android

Native libraries, which use

C

Or

C ++

It is very closely integrated with hardware. Important native libraries include:

Surface Manager

: Management of the display subsystem, similar

Vista

Or

Compiz

But it is much simpler than these.

2d

And

3G graphics

: In

Android

, A single user interface can be

2d

Or

3D

. Provide

2d

And

3D

Rendering and processing. For example

OpenGL

.

Media codecs

:

Android

It provides encoding and decoding functions for most mainstream audio and video.

SQL

Database: In

Android

Provides a lightweight

SQLite

Database engine, which is also in

Firefox

And Apple's

IPhone

. It stores data persistently.

Browser Engine

: For faster display

Html

Content,

Android

Used

WebKit

Library.

System Runtime Library

The system Runtime Library is mainly composed

Dalvik

Virtual machines and

Java

Core library.

Application Framework

Activity Manager (

Activity Manager

): Controls the lifecycle of an application and provides common navigation rollback functions.

Content Providers (

Content Providers

): Enables the application to access data of another application.

(

Such as the contact database

)

,

Or share their own data.

Resource Manager (

Resource Manager

): Provide

Non-code resource access, such as local strings, graphics, and layout files.

Location Manager (

Location Manager

): Any part

Android

The operating system's mobile phone can recognize the location.

Notification Manager (

Notification Manager

): Enables the application to display custom prompts in the status bar.

Applications and

Widgets

This is the highest level of the system architecture, mainly including dialing, sending emails, contact management,

Web

Browsing and other applications and gadgets that users often use.

2.2

Activity lifecycle and transition

 

Every activity (

Activity

) Is in a certain state. for developers, it is impossible to control their applications in a certain state, and these are all done by the system. However, when the status of an activity changes, you can call

Onxx ()

To obtain the relevant notification information.

In implementation

Activity

When (

Override

) These methods can be called when you need to process them.

Oncreate

: This method is triggered when the activity is started for the first time. The initialization of the activity can be completed at this time.

Oncreate

Method has a parameter, which can be null (

Null

).

Onsaveinstancestate

() Status information saved by the method.

Onstart

: The trigger of this method indicates that the activity will be displayed to the user.

Onresume

: This method is triggered when an activity interacts with the user.

Onpause

: This method is triggered when an activity that is running on the foreground is transferred to the background for running because other activities need to be run on the foreground. At this time, the activity status should be persistent, such as the database records being edited.

Onstop

: This method is triggered when an activity no longer needs to be presented to users. If the memory is insufficient, the system will directly end the activity without triggering it.

Onstop

Method.

Onrestart

: This method is triggered when a stopped activity needs to be displayed to the user again.

Ondestroy

: This method is triggered when the activity is destroyed. And

Onstop

The method is the same. If the memory is insufficient, the system will directly end this activity without triggering this method.

Onsaveinstancestate

: The system calls this method to allow the activity to save the previous state, such as the position of the cursor in a string. Generally, developers do not need to override this method. In the default implementation, all the status information of the user interface components involved in the activity is automatically saved.

 

The activity will be stopped or

Linux

Management Processes end these activities at any time to reserve sufficient storage space for new activities. Therefore, developers must always keep this principle in mind when designing applications. In some cases,

Onpause

The method may be the final method of event triggering. Therefore, developers need to save the information to be saved at this time.

 

2.3

Components

In

Android

Many important components are provided in the system. For developers, the most important activities (

Activites

), Intention (

Intents

),

Service

(Service), content providers (

Content Providers

).

Activity (

Activities

)

The activity is simply a user interface. Applications can be composed of multiple user interfaces, corresponding to different stages.

Intention (

Intents

)

Intent

Is a mechanism to describe an operation, such as getting a photo. In

Android

In the system, almost all work passes

Intent

Therefore, developers often need

Intent

Deal.

Service (

Services

)

A service is a program that runs in the background and does not directly interact with users, such

UNIX

. For example, a music player (

Activity

) Start playing the music, and then you can run other software without shutting down the playing music.

Content Providers (

Content
Provider

)

The content provider is a set of data that encapsulates read/write methods. Using this method can better share global data among different applications.

 

2.4

Resources

A resource is a localized string, bitmap, or other non-program code. When compiling an application, these resources will be compiled into the application.

 

2.5

Security

Because

Android

Is based on

Linux

Operating system, so the running management of its applications and

Linux

Similarly, each application runs on its own

Linux

Process space. The hardware platform prohibits processes from accessing the memory space of other processes. In addition, each application is labeled with a specific user number, and any files it creates cannot be accessed by other applications.

In addition, access critical operations are strictly controlled and must be performed in

Androidmanifest. xml

File. Package Manager (

Package Manager

) According to the application. The following are some important permissions:

Internet

: Access the internet.

Read_contacts

: Read user contact data

Write_contacts

: Write user contact data

Receive_sms

: Monitor received text information

Access_coarse_location

: Call the primary positioner, such

WiFi

Access_fine_location

: Call an exact locator, for example

GPS

For example, to receive SMS monitoring, You need to configure the following:

<Manifest
Xmlns: Android = "http://schemas.android.com/apk/res/android"

Package = "com. Google. Android. App. MyApp"
>

<Uses-Permission
Android: Name = "android. Permission. receive_sms"/>

</Manifest>

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.