Implementing IPC Using AIDL

Follow these steps to implement an IPC service using AIDL.

1. Create your .aidl file - This file defines an interface (YourInterface.aidl) that defines the methods and fields available to a client.

2. Add the .aidl file to your makefile - (the ADT Plugin for Eclipse manages this for you). Android includes the compiler, called AIDL, in the tools/ directory.

3. Implement your interface methods - The AIDL compiler creates an interface in the Java programming language from your AIDL interface. This interface has an inner abstract class named Stub that inherits the interface (and implements a few additional methods necessary for the IPC call). You must create a class that extends YourInterface .Stub and implements the methods you declared in your .aidl file.

4. Expose your interface to clients - If you're writing a service, you should extend Service and override Service.onBind(Intent) to return an instance of your class that implements your interface.

0 0

Post a comment