Today I am going to show you how to create Android Interface Definition Language (AIDL) Android AIDL Example. Each application in Android runs in its own process. An application cannot directly access the data of another application for security reasons. If you want access the data from another application then AIDL will help you to access those data. I have created two example one of Server which create the AIDL service and second Client which acces the server data.

 

Server Example : 

1.) Create the aidl file on your package as following (IRemote.aidl).

I have only created the add method on the interface IRemote

2.) Create the Service and Bind the IRemote Service as following

3.) Mention the service to android manifest file as following

and also mention the action name that is important I mentioned “com.remote.service.CALCULATOR”

Client Example : 

1.) In the client example i show you how to access server data create. Create the same aidl package as you used in the server example  and create the same(copy) file as you created in the server example IRemote.aidl

2.) create the xml file (main.xml) as following

3.) create the activity (MainActivity.java) as following

I have created the service connection and create the IRemote aidl object to acces the data this will return addition of two numbers.

 

Download source code