On Android Framework

Source: Internet
Author: User

Recent work tasks are not busy, learn about the Android framework knowledge.

First, Introduction, what is

Android's framework is a layer of direct application, called the application framework layer. This layer is the API framework used by core applications, providing APIs for the application layer and providing a variety of components and services to support our Android development, including Activitymanager,windowmanager,viewsystem. Below is a list of Android system architecture diagrams that are common to learning Android:

second, what is

The Android framework Framework contains 3 main parts: Server, client, Linux driver.

let's start by describing what's important on the service side:
    1. Activitymanagerservice (AMS): Responsible for managing activity in all applications, it has all the activity, has all the ability to schedule the activity life cycle, simply speaking, Activitymanagerservice is the management and control of all activity.
    2. Windowmanagerservice (WMS): Controls the display, hiding, and sequence of Windows, simply, it is the management window, and most of the view is related to it.
    3. Keyq class: It is an internal class of WMS that, once created, initiates a new thread that continuously receives and reads the user's UI action messages and places them in message queue queueevent.
    4. Inputdispatcherthread class: This class is also a new thread that will be started once it is created, and the thread will continuously remove the user's messages from the queueevent above and then send the messages to the currently active client program.
Here are some things that are important to the client:
  1. Activitythread class: The main thread class, which is the UI thread class, our program entry is from the Activitythread main () function entry. It is based on the requirements of AMS (via the Iapplicationthread interface, AMS for Client,activitythread.applicationthread Server) to dispatch and execute activities, Broadcasts and other operations.
  2. Viewroot class: A very important class that is responsible for client interaction with the WMS: The inner class has the W class, the W class inherits from Binder, so he is similar to the Applicationthread role, except that it corresponds to the WMS, when the WMS wants to communicate with the client, This class is called by the WMS. Internally, the Viewroothandler class inherits from the handler, so he can send the message to the UI thread after the W class receives the WMS message. At the same time, the starting point of interface drawing is also in this area: Performtraversals ();
  3. W class: Viewroot helper, inheriting with binder, is the viewroot inner class. Primarily helps Viewroot implement an asynchronous call to convert the IPC (interprocess communication) Call of the WMS to Local.
  4. Activity class: This class we are more familiar with, apk run the smallest unit.
  5. Phonewindow Class: Inherited from the window class, it will put a decorview, it provides a set of unified window operation of the API.
  6. Window class: Provides some common Windows operations APIs.
  7. Decorview class: This is all the view we can see, it inherits from the Framelayout, and the layout view we write is placed in it.
  8. Applicationthread class: Inherit the fish binder, when AMs wants to communicate with the client (that is, when invoking the client's method), this class is called by AMs.
  9. Instrumentation class: is responsible for directly with the AMS dialogue, such as when the client wants to communicate with AMS (that is, call the AMS service method), it is to implement a single call to AMS, all want to invoke the AMS operation is centralized to it here, it is responsible for one-way call AMs.
  10. WindowManager: If you want to create a window, you have to tell WindowManager first, and then it communicates with Windowmanagerservice to see if it can be created, and the client cannot interact directly with the WMS.
Linux drivers:

Linux drives and the framework are mainly related to two parts: painter Surfaceflingger and Courier Binder. Each window corresponds to a painting surface,sf is the main display of each surface on the same screen. Binder is the delivery of messages across processes.

Manager mechanism:

The server has a lot of various system services, when the client wants to invoke these services every time (IPC) if you want a service directly to call which service, it will appear more chaotic and poor extensibility, so Android uses this manager mechanism, That is, to set up a manager-like thing, the manager, it is a service itself, and it manages all the other services, that is, we need which service to go through it first, it is responsible for us to call this service, so it only give us exposed to a manager this service, Other services were blocked by him, much like the Java package.

Finally, summarize the three core functions of Android framework: 1, View.java:View working principle, implementation includes drawing View, processing touch, key events and so on. 2, ACTIVITYMANAGERSERVICE.JAVA:AMS management of all application activity and so on. 3. WindowManagerService.java:Wms assigns Windows to all applications and manages these windows.

On Android Framework

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.