From 0c11b990908df26aca7f017d330535b9bf21a903 Mon Sep 17 00:00:00 2001
From: Scott Main Since each application runs in its own process, and you can write a service that
runs in a different process from your Application's UI, sometimes you need to pass objects
between processes. On the Android platform, one process can not normally access the memory
@@ -10,7 +29,7 @@ the operating system can understand, and "marshall" the object across that bound
The code to do that marshalling is tedious to write, so we provide the AIDL tool to do it
for you. AIDL (Android Interface Definition Language) is an AIDL (Android Interface Definition Language) is an IDL
language used to generate code that enables two processes on an Android-powered device
to talk using interprocess communication (IPC). If you have code
@@ -20,12 +39,9 @@ generate code to marshall the parameters. The AIDL IPC mechanism
is interface-based, similar to COM or Corba, but lighter weight. It uses a proxy
class to pass values between the client and the implementation. This page includes the following main topics: Follow these steps to implement an IPC service using AIDL.In this document
+
+Implementing IPC Using AIDL
+
+
+Implementing IPC Using AIDL
AIDL is a simple syntax that lets you declare an interface with one or more
methods, that can take parameters and return values. These parameters and return
values can be of any type, even other AIDL-generated interfaces. However, it
@@ -117,7 +134,7 @@ interface IBankAccountService {
int getCustomerList(in String branch, out String[] customerList);
}
- AIDL generates an interface file for you with the same name as your .aidl
file. If you are using the Eclipse plugin, AIDL will automatically be run as part of
the build process (you don't need to run AIDL first and then build your project).
@@ -152,7 +169,7 @@ private final IRemoteService.Stub mBinder = new IRemoteService.Stub(){
Now that you've got your interface implementation, you need to expose it to clients.
This is known as "publishing your service." To publish a service,
inherit {@link android.app.Service Service} and implement {@link android.app.Service#onBind
@@ -165,8 +182,8 @@ private final IRemoteService.Stub mBinder = new IRemoteService.Stub(){
exposing_a_service}
}
-
- If you have a class that you would like to send from one process to another through
an AIDL interface, you can do that. You must ensure that the code for your class is available
@@ -181,25 +198,12 @@ current state of the object and writes it to a parcel.
value in a parcel into your object.
AIDL will use these methods and fields in the code it generates to marshall and unmarshall
your objects. Here is an example of how the {@link android.graphics.Rect} class implements the
@@ -269,7 +273,7 @@ values for whatever the caller is trying to do. See
Security and Permissions for more
on how to keep your application secure from malware. Here are the steps a calling class should make to call your remote interface: Implementing the Interface
+Implementing the Interface
Exposing Your Interface to Clients
+Exposing Your Interface to Clients
Pass by value Parameters using Parcelables
+
+Pass by value Parameters using Parcelables
CREATOR to your class which is an object implementing
the {@link android.os.Parcelable.Creator Parcelable.Creator} interface.
-
-
-
-Calling an IPC Method
+Calling an IPC Method