. NET programmer play to Android Series II ~android Framework Overview (1)

Source: Internet
Author: User

Speaking from the Windows operating system

People are always fond of associating unfamiliar things with what they know, in order to deepen their understanding of the unknown, which we start from the Windows operating system and gradually lead us into the world of Android. Writing any program needs to know the principles and environment of the program, such as the development of the WinForm program, you need to know at least the operating system principle, the CLR runtime, to understand some of the commonly used C + + libraries. It's true that you don't need to know well enough to write very good apps, but the more you know and delve deeper, the more you can develop more optimized applications for your platform. For example, on a Windows operating system, your program runs like this:

So how is your program running on Android? A picture wins thousands of words:

In order not to let friends come in and see addlebrained, this picture I simplified a lot, briefly introduced:

Linux kernel: A driver that manages your phone's hardware, including camera drivers, bluetooth drivers, wifi drivers, and more, for upper-level calls. You're right, Android is a sophisticated Linux kernel.

C + + libraries: Libraries for C/s + +, including Webkit,opengl (see friends who like to play games here), the most important thing is to include a sqllite, you do not read wrong, like early adopters. NET friends have played the most popular embedded database, in your mobile phone is lying. Your contacts, the text messages, all exist in this one. (to the sister's contact AH SMS Ah, what bad idea, well, to trust each other.) )

Android Runtime : The most important thing here is the Dalvik virtual machine . We know that the Java application runs on the JVM virtual machine (equivalent to the CLR runtime), obviously the power consumption of the phone and the PC can not be compared, so Google has done a lot of optimizations to the JVM, so the birth of the Dalvik virtual machine, the original Java application run in the way: xx.java- >XX.CLASS->JVM execution, now the Java application is executed as follows: Xx.java->xx.class->xx.dex->dalvik execution. This is a few people in mind, although we are quick Android, but also quality and quantity:)

Android Framework: Android provides a range of Java system services for applications to invoke to implement functionality.

Booting from your phone-explaining the Android startup process

Direct:

A brief description is as follows:

an android boot will first load the Linux Kernerand then start the Init process, which is consistent with the Linux system.

The two init process initializes various devices, as described below:

  1 Zygote: Every time a Java application runs, Zygote derives a child process to execute the Java application, which is the virtual machine used to execute the Java application.

  2 system Server : A core process of the Android system, derived from the zygote process, establishes most of the Java Services for Android, such as geolocation information services.

  3 Media Server: Run Local System -based services, such as cameras.

  4 Content Manager: This is an implementation of an adapter pattern, whether it is a local/C + + service or a System Java service, which is reported here, and finally unified to provide API calls to Java applications.

  5 daemons: Connection Management Service. Includes USB connection management, wireless communication connection management, and most importantly, ADB (Android debugger Birdge) connection management , which allows you to display the exception information that is running on your phone in your eclipse. We'll use that later.

This diagram brings out one of Android's most important four core concepts: Service . That is, most of the features of Android are in the form of services, whether you are IPC for interprocess communication, or remote procedure call RPC, in Android is called a series of services, this is not a bit like SOA architecture. The final goal of software design is to be easy to maintain, easy to expand, easy to reuse and so on. Decoupling is one of the key steps. It seems that no matter. NET or Android, the idea of software is universal. What do you say?

Here is a simple introduction to the JNI and NDK, from the above explained that we know that the local library of Android, although the form of services registered in the context manager, but if the existing registered services can not meet the functionality, but you know its local library has such a function, what to do? We are in the. Net BCL API, in fact, there are some calls to the operating system of the lower-C + + Write library, in this case, we can understand that the library written in these C/s. NET in the "registration", the reason for the quotation mark I believe you understand, that is not registered C/T function we can not use it? Of course, we have P/invoke, then Java, of course, there is JNI (Java Native Interface), of course, others in addition to the Java can call the C + + library function, but also in C/C + + Call Java class function, Really bright blind my eyes, someone asked how to call? Is Java execution not a virtual machine? Well, they provide the virtual machine interface to you, you can load the virtual machine in the memory area of C + +, and invoke the method of specifying Java class ...

Given that JNI is cumbersome to write, in order to facilitate JNI programming and improve development efficiency, Google has provided the NDK suite, which facilitates the invocation of Java and C + + programs, so that Java and C + + programs can be exchanged. Today's high-end Android programmers are basically dealing with these things.

Have to say, someone else Google really has a realm, the people who work inside, can really call the programmer it.

Next talk

This talk about our simple understanding of the framework of the Android framework, although we are quick type, but not in the floating sand building the idea has been my motto, rather unfamiliar with grammar, not familiar with the API, not familiar with the programming, but the underlying principle leng to be clear, This is the only way to grow into a high-end programmer.

Next we will complete the Android environment build and Hello World, while gradually introducing the remaining three core concepts in Android.

The recent preparation of the system architect design exam is also relatively busy. When will the next blog come out, see the recommended number:)

. NET programmer play to Android Series II ~android Framework Overview (1)

Related Article

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.