Wednesday 27 February 2013

AIDL - Android Interface Definition Language

 
AIDL – Android Interface Definition Language is an IDL language used to generate code that enables two process on an Android-powered device to talk using inter process communication(IPC). If you have code in one process that needs to call on an object on another process, you would use AIDL to generate code to marshall the parameters.

Implementing IPC using AIDL

To implement an IPC service using AIDL

  1. Create your .aidl file – This file defines an interface that defines the methods and fields available to a client.
  2. Add the .aidl file to your make file. 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 . You must create a class that extends your interface 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 retain an instance of your class that implements your interface.

No comments:

Post a Comment