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.