The Android system is a house with a normal operating company stationed in this seat
The CPU is the boss of this company
The process is the office in the company, the Office does not work
A thread is an employee in an office, always a worker.
There can be more than one employee in an office, and there is an activity outside the office called the main thread
The company will certainly have many functional departments
Activity service provider Brocastrecive are all functional departments
Now the company has a customer needs, need several departments to work together to complete, so the company's business staff app with the boss applied for an office to complete customer demand work
Of course, in order to work more effectively, some departments may need a separate office is also possible
The above is the understanding of these concepts in Android, summed up the following:
Android system is multi-process, but not the more the better, the process is open too much, the system will be stuck
Each launch of an app, the system will open up a new process, in general, the four components of the app are running in the same process, and the same thread
If you configure the component's process in the Mainifest.xml file (: XXX is the system global pooled process. XXX is a common process for the current app), then the component can run independently in a separate process
So, there's the Aidl technology, the communication between the processes
Aidl is an interface description language and can also be understood as an interface between Java processes (interface)
Write a Java interface class directly, After the suffix is changed to. aidl after compiling, in the Gen directory will generate a Java class, and this class has an abstract class, in the server implementation of this abstract class, and through the Onbind method to return to the client, you can use this object in the client process to invoke the method in the server process, to achieve communication
It can be seen that aidl technology is actually similar to the binding service usage, the difference is that the binding service is the Java file to define the interface, and Aidl is through the Aidl file to define the interface, and tested, the same process can certainly be used aidl, that is, Bind service can be replaced by aidl
Next service:
The service is bound by the Bundservcie method call, Onbundservice deactivated, and when the caller destroys, as in an activity called, when the aictivity is destroyed, the service is destroyed.
The global service, which is disabled by the StartService method call, StopService deactivated, and when the caller destroys it, the service is still running, and the service is destroyed only when exiting the app, and, of course, the service can be kept running through daemon technology
The above is only a personal understanding, if there is a mistake, please help pointing twos
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
About Android thread, process, component, app understanding