Written in the previous words:
About the use of aidl in remote service to achieve cross-process, multi-threaded communication, I refer to three articles, probably to figure this out.
(1) Android official documentation for AIDL
Docs/guide/components/aidl.html
(2) Android Learning note service AIDL and remote service implementation process communication and inter-process custom type parameters
http://blog.csdn.net/honeybaby201314/article/details/19989455
(3) Android Aidl use detailed
http://blog.csdn.net/stonecao/article/details/6425019
Official description of Aidl:
Aidl (Android Interface Definition Language) is similar to other Idls you might has worked with. It allows define the programming interface that both the client and service agree upon in order to communicate with Each of the other using interprocess communication (IPC).
Aidl (Android Interface Definition language) is similar to Idls, where he mainly defines the client-server unified programming interface for client-to-server cross-process communication (IPC).
Where to use Aidl:
Note:using Aidl is necessary only if you allow clients from different applications to access your service for IPC and WAN T to handle multithreading in your service. If you don't need to perform concurrent IPC across different applications, you should create your interface by Implementi ng a Binder or, if you want to perform IPC, but does not need to handle multithreading, implement your interface using a Mes Senger.
If clients wants to access the service across processes from different applications, it handles multithreaded operations in the service. We will only use Aidl. If cross-processes are not required, we can create interfaces that implement binders, and if we need to communicate across processes, but do not need to handle multithreaded operations, then we can use Messager.
How to use Aidl:
To create a bounded service using AIDL, follow these steps:
1. Create the. aidl file
This file defines the programming interface with method signatures.
2. Implement the interface
The Android SDK tools generate an interface in the Java programming language, based on your. aidl file. This interface have an inner abstract class named Stub, extends Binder and implements methods from your Aidl interface. You must extend the Stub class and implement the methods.
3. Expose the interface to clients
Implement a Service and override Onbind () to return your implementation of the Stub class.
Detailed steps for aidl use
I wrote a demo with an official document and another example to illustrate how aidl can be used.
(1) Client
(2) Service side
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Aidl of Android Learning remote service