Android framework -- activitymanager framework

Source: Internet
Author: User

1. activitymanager is an important part of the android framework. It is responsible for the creation of a new activitythread process and maintenance of the activity lifecycle. This blog begins to understand the activitymanager framework as a whole.
2. first look at a static class structure:

This figure is taken from Cao Wenbin's blog <activity manager framework analysis>
The relationship between several main classes in the activitymanager framework is clearly described. Many of our application development contacts are actually the activitymanager class, which is also published in the SDK and can be accessed directly by applications, it provides some basic methods for us to manage activities.
As follows:
Public void testgetrecenttasks ()
// Obtain the most recent application and start the sorting
Public void testgetrunningtasks ()
// Obtain the currently running activity Application
Public void testgetrunningservices ()
// Obtain the currently running service application
Public void testgetrunningappprocesses ()
// Obtain the processes run by the System
These operations depend on The Implementation of The activitymanagerproxy proxy class. The iactivitmanager interface defines all the operations in the activitymanager framework. activitymanagerproxy implements the iactivitmanager interface, but does not actually implement these methods. It is just a proxy class, the real action execution is the stub activitymanagerservice. Only one activitymanagerservice object exists in the system_process process. activitymanagerservice inherits from the activitymanagernative root class.
3. according to the previous analysis, activitymanager exists in the user process and is called by the user process to obtain some basic information about activity management. However, the activitymanager class does not actually execute these operations, activitymanagerservice and activitymanagerservice in the system_process process are loaded as a service when system_process is started. We will not discuss how activitymanagerservice is loaded here, later, we will discuss how to start the Android system. From activitymanager to activitymanagerservice, we will go through a process communication link, while iactivitymanager and activitymanagerproxy, the proxy class that implements the interface, the stub activitymanagernative plays a role in Process Communication. The implementation mechanism of OG aidl has made a deep analysis on Process Communication. Although the aidl file is not used to define the process Communication Interface iactivitymanager, it is actually the same, we can regard it as a self-compiled aidl Process Communication Java class implementation. activitymanagerproxy is the proxy class, activitymanagernative is the stub class, And iactivitymanager is the aidl interface, which is easy to understand.
4. activitymanager provides a few methods. To use other methods provided by the iactivitymanager interface, we can directly use the activitymanagerproxy object. How can we obtain them?
Return activitymanagernative. getdefault ()
Do not be confused by the method name. Because we call the method in the user process, it is impossible to obtain an activitymanagernative object (and activitymanagernative is an abstract class). What we actually get is an activitymanagerproxy object.
Understanding the basic structure of the above activitymanager framework is much easier to study later.

Original article: http://blog.csdn.net/stonecao/article/details/6579710

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.