Android Core Component Service (5)

Source: Internet
Author: User

In a remote Service call, how does the Activity communicate with the Service? For remote Service calls, there are usually two different processes in different projects. What is the process communication mechanism? I drew a picture to illustrate it.

 

Click to view the chart

During remote communication, the Android process will:

1. Generate a main thread.

2. Generate a logoff object

3. Generate a message queue.

4. Generate a virtual machine object to implement communication between Java and C ++.

5. Remote Communication is achieved through the C/C ++-layer IPC.

Inter-process communication: Android uses the IBinder interface to implement inter-process communication. MyActivity calls the IBinder's transact () function and calls the remote onTransact () function through IPC. Note: by default, if the Service and Activity and BroadcastReceiver are in the same project, these components will be executed in the same process and the main thread will be responsible for the execution, of course, you can also configure it to run in different components. For example, in the previous section, we let the Service run in the Remote process.

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.